Class: Neoid::SingleResultPromiseProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/neoid/batch.rb

Overview

returned from adding (<<) an item to a batch in a batch block: Neoid.batch { |batch| (batch << [:neography_command, param]).is_a?(SingleResultPromiseProxy) } so a ‘.then` can be chained: Neoid.batch { |batch| (batch << [:neography_command, param]).then { |result| puts result } } the `then` is called once the batch is flushed with the result of the single job in the batch it proxies all methods to the result, so in case it is returned (like in Neoid.execute_script_or_add_to_batch) the result of the method will be proxied to the result from the batch. See Node#neo_save

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSingleResultPromiseProxy

Returns a new instance of SingleResultPromiseProxy.



143
144
# File 'lib/neoid/batch.rb', line 143

def initialize(*)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



153
154
155
# File 'lib/neoid/batch.rb', line 153

def method_missing(method, *args)
  result.send(method, *args)
end

Instance Attribute Details

#resultObject

Returns the value of attribute result.



146
147
148
# File 'lib/neoid/batch.rb', line 146

def result
  @result
end

Instance Method Details

#perform(result) ⇒ Object



162
163
164
165
166
# File 'lib/neoid/batch.rb', line 162

def perform(result)
  @result = result
  return unless @then
  @then.call(result)
end

#then(&block) ⇒ Object



157
158
159
160
# File 'lib/neoid/batch.rb', line 157

def then(&block)
  @then = block
  self
end