Class: Q::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/q/callback.rb

Instance Method Summary collapse

Constructor Details

#initialize(promise, block) ⇒ Callback

Returns a new instance of Callback.



2
3
4
5
# File 'lib/q/callback.rb', line 2

def initialize(promise, block)
  @promise = promise
  @block = block
end

Instance Method Details

#call(result) ⇒ Object



7
8
9
10
11
12
# File 'lib/q/callback.rb', line 7

def call(result)
  unless @called
    @block.call(result)
    @called = true
  end
end