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

Inherits:
BasicObject
Defined in:
lib/roby/interface/v1/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



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

def initialize(context)
    @context = context
    @calls = []
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



472
473
474
475
476
477
478
479
480
481
# File 'lib/roby/interface/v1/client.rb', line 472

def method_missing(m, *args) # rubocop:disable Style/MethodMissingSuper
    if (action_match = /(.*)!$/.match(m.to_s))
        return start_job(action_match[1], *args)
    end

    ::Kernel.raise ::NoMethodError.new(m),
                   "#{m} either does not exist, or is not "\
                   "supported in batch context (only "\
                   "starting and killing jobs is)"
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



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

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



485
486
487
# File 'lib/roby/interface/v1/client.rb', line 485

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



432
433
434
# File 'lib/roby/interface/v1/client.rb', line 432

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



454
455
456
# File 'lib/roby/interface/v1/client.rb', line 454

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)


422
423
424
# File 'lib/roby/interface/v1/client.rb', line 422

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



461
462
463
# File 'lib/roby/interface/v1/client.rb', line 461

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)


465
466
467
# File 'lib/roby/interface/v1/client.rb', line 465

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:



441
442
443
444
445
446
447
448
449
# File 'lib/roby/interface/v1/client.rb', line 441

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