Class: Promise::Trace
Instance Attribute Summary
Attributes inherited from Promise
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(depth, block) ⇒ Trace
constructor
A new instance of Trace.
Methods inherited from Promise
#<<, #>>, #^, #act?, #action, #always, #each, error, #exception!, #exception?, #fail, #inspect, #method_missing, #realized?, #reject, #reject!, #rejected?, #resolve, #resolve!, #resolved?, #respond_to_missing?, #sync, #then, #to_json, #trace, #value, value, #value_or_error, when
Constructor Details
#initialize(depth, block) ⇒ Trace
Returns a new instance of Trace.
340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/volt/utils/promise.rb', line 340 def initialize(depth, block) @depth = depth super success: -> { trace = Trace.it(self).reverse trace.pop if depth && depth <= trace.length trace.shift(trace.length - depth) end block.call(*trace) } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Promise
Class Method Details
.it(promise) ⇒ Object
326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/volt/utils/promise.rb', line 326 def self.it(promise) current = [] if promise.act? || promise.prev.nil? current.push(promise.value) end if prev = promise.prev current.concat(it(prev)) else current end end |