Class: Lexster::SingleResultPromiseProxy
- Inherits:
-
Object
- Object
- Lexster::SingleResultPromiseProxy
- Defined in:
- lib/lexster/batch.rb
Overview
returned from adding (<<) an item to a batch in a batch block: Lexster.batch { |batch| (batch << [:neography_command, param]).is_a?(SingleResultPromiseProxy) } so a ‘.then` can be chained: Lexster.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 Lexster.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
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(*args) ⇒ SingleResultPromiseProxy
constructor
A new instance of SingleResultPromiseProxy.
- #method_missing(method, *args) ⇒ Object
- #perform(result) ⇒ Object
- #then(&block) ⇒ Object
Constructor Details
#initialize(*args) ⇒ SingleResultPromiseProxy
Returns a new instance of SingleResultPromiseProxy.
143 144 |
# File 'lib/lexster/batch.rb', line 143 def initialize(*args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
153 154 155 |
# File 'lib/lexster/batch.rb', line 153 def method_missing(method, *args) result.send(method, *args) end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
146 147 148 |
# File 'lib/lexster/batch.rb', line 146 def result @result end |
Instance Method Details
#perform(result) ⇒ Object
162 163 164 165 166 |
# File 'lib/lexster/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/lexster/batch.rb', line 157 def then(&block) @then = block self end |