Class: Roby::Interface::Client::BatchContext Private

Inherits:
BasicObject
Defined in:
lib/roby/interface/client.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Object used to gather commands in a batch

Defined Under Namespace

Classes: Return

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ BatchContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new batch context

Parameters:

  • context (Object)

    the underlying interface object



363
364
365
366
# File 'lib/roby/interface/client.rb', line 363

def initialize(context)
    @context = context
    @calls = ::Array.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Provides the action_name! syntax to start jobs



416
417
418
419
420
421
422
# File 'lib/roby/interface/client.rb', line 416

def method_missing(m, *args)
    if m =~ /(.*)!$/
        start_job($1, *args)
    else
        ::Kernel.raise ::NoMethodError.new(m), "#{m} either does not exist, or is not supported in batch context (only starting and killing jobs is)"
    end
end

Instance Method Details

#__callsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The set of operations that have been gathered so far



373
374
375
# File 'lib/roby/interface/client.rb', line 373

def __calls
    @calls
end

#__processObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Process the batch and return the list of return values for all the calls in #__calls



426
427
428
# File 'lib/roby/interface/client.rb', line 426

def __process
    @context.process_batch(self)
end

#__push(path, m, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Pushes an operation in the batch



378
379
380
# File 'lib/roby/interface/client.rb', line 378

def __push(path, m, *args)
    @calls << [path, m, *args]
end

#drop_job(job_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Drop the given job within the batch

Note that as all batch operations, order does NOT matter



398
399
400
# File 'lib/roby/interface/client.rb', line 398

def drop_job(job_id)
    __push([], :drop_job, job_id)
end

#empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


368
369
370
# File 'lib/roby/interface/client.rb', line 368

def empty?
    @calls.empty?
end

#kill_job(job_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Kill the given job within the batch

Note that as all batch operations, order does NOT matter



405
406
407
# File 'lib/roby/interface/client.rb', line 405

def kill_job(job_id)
    __push([], :kill_job, job_id)
end

#respond_to_missing?(m, include_private) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


409
410
411
# File 'lib/roby/interface/client.rb', line 409

def respond_to_missing?(m, include_private)
    (m =~ /(.*)!$/) || super
end

#start_job(action_name, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Start the given job within the batch

Note that as all batch operations, order does NOT matter

Raises:



387
388
389
390
391
392
393
# File 'lib/roby/interface/client.rb', line 387

def start_job(action_name, *args)
    if @context.has_action?(action_name)
        __push([], :start_job, action_name, *args)
    else
        ::Kernel.raise ::Roby::Interface::Client::NoSuchAction, "there is no action called #{action_name} on #{@context}"
    end
end