Class: Syncano::BatchQueueElement

Inherits:
Object
  • Object
show all
Defined in:
lib/syncano/batch_queue_element.rb

Overview

Class representing objects batch requests queued for processing

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ BatchQueueElement

Constructor for Syncano::BatchQueueElement



6
7
8
9
# File 'lib/syncano/batch_queue_element.rb', line 6

def initialize(resource)
  super()
  self.resource = resource.dup
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Syncano::BatchQueueElement

Overwritten method_missing used for preparing execution of proper batch method on the resource object

Parameters:

  • sym (Symbol)
  • args (Array)
  • block (Proc)

Returns:



16
17
18
19
20
21
# File 'lib/syncano/batch_queue_element.rb', line 16

def method_missing(sym, *args, &block)
  self.method_name = 'batch_' + sym.to_s
  self.args = args
  self.block = block
  self
end

Instance Method Details

#perform!(batch_client) ⇒ Object

Executes batch method on the resource object



24
25
26
27
# File 'lib/syncano/batch_queue_element.rb', line 24

def perform!(batch_client)
  args.unshift(batch_client)
  resource.send(method_name, *args, &block)
end