Class: Roby::Interface::V2::Client::BatchContext Private
- Inherits:
- BasicObject
- Defined in:
- lib/roby/interface/v2/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
-
#__calls ⇒ Object
private
The set of operations that have been gathered so far.
-
#__process ⇒ Object
private
Process the batch and return the list of return values for all the calls in #__calls.
-
#__push(path, m, args, keywords = {}) ⇒ Object
private
Pushes an operation in the batch.
-
#drop_job(job_id) ⇒ Object
private
Drop the given job within the batch.
- #empty? ⇒ Boolean private
-
#initialize(context) ⇒ BatchContext
constructor
private
Creates a new batch context.
-
#kill_job(job_id) ⇒ Object
private
Kill the given job within the batch.
-
#method_missing(m, **keywords) ⇒ Object
private
Provides the action_name! syntax to start jobs.
- #respond_to?(m, _include_private = false) ⇒ Boolean private
-
#start_job(action_name, **arguments) ⇒ Object
private
Start the given job within the batch.
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
423 424 425 426 |
# File 'lib/roby/interface/v2/client.rb', line 423 def initialize(context) @context = context @calls = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, **keywords) ⇒ 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
482 483 484 485 486 487 488 489 490 491 |
# File 'lib/roby/interface/v2/client.rb', line 482 def method_missing(m, *, **keywords) # rubocop:disable Style/MethodMissingSuper if (action_match = /(.*)!$/.match(m.to_s)) return start_job(action_match[1], **keywords) 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
#__calls ⇒ 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.
The set of operations that have been gathered so far
433 434 435 |
# File 'lib/roby/interface/v2/client.rb', line 433 def __calls @calls end |
#__process ⇒ 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.
Process the batch and return the list of return values for all the calls in #__calls
495 496 497 |
# File 'lib/roby/interface/v2/client.rb', line 495 def __process @context.process_batch(self) end |
#__push(path, m, args, keywords = {}) ⇒ 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
438 439 440 |
# File 'lib/roby/interface/v2/client.rb', line 438 def __push(path, m, args, keywords = {}) @calls << [path, m, args, keywords] 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
460 461 462 |
# File 'lib/roby/interface/v2/client.rb', line 460 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.
428 429 430 |
# File 'lib/roby/interface/v2/client.rb', line 428 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
467 468 469 |
# File 'lib/roby/interface/v2/client.rb', line 467 def kill_job(job_id) __push([], :kill_job, [job_id]) end |
#respond_to?(m, _include_private = false) ⇒ 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.
471 472 473 474 475 476 477 |
# File 'lib/roby/interface/v2/client.rb', line 471 def respond_to?(m, _include_private = false) return true if BatchContext.method_defined?(m) return unless (action_match = /(.*)!$/.match(m.to_s)) @context.has_action?(action_match[1]) end |
#start_job(action_name, **arguments) ⇒ 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
447 448 449 450 451 452 453 454 455 |
# File 'lib/roby/interface/v2/client.rb', line 447 def start_job(action_name, **arguments) if @context.has_action?(action_name) __push([], :start_job, [action_name], arguments) else ::Kernel.raise ::Roby::Interface::V2::Client::NoSuchAction, "there is no action called #{action_name} "\ "on #{@context}" end end |