Class: EMDextras::Chains::JoinedDeferrable
- Inherits:
-
Object
- Object
- EMDextras::Chains::JoinedDeferrable
- Includes:
- EventMachine::Deferrable
- Defined in:
- lib/em-dextras/chains.rb
Instance Method Summary collapse
-
#initialize(deferrables) ⇒ JoinedDeferrable
constructor
A new instance of JoinedDeferrable.
- #one_callback(*vs) ⇒ Object
- #one_errback(*vs) ⇒ Object
Methods included from EventMachine::Deferrable
Constructor Details
#initialize(deferrables) ⇒ JoinedDeferrable
Returns a new instance of JoinedDeferrable.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/em-dextras/chains.rb', line 7 def initialize(deferrables) result_pairs = deferrables.map do |deferrable| [deferrable, :unset] end @results = Hash[result_pairs] @callback_values = [] @errback_values = [] initialize_deferrables! end |
Instance Method Details
#one_callback(*vs) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/em-dextras/chains.rb', line 18 def one_callback(*vs) deferrable, *values = vs @results[deferrable] = :ok @callback_values.push *values check_if_complete end |
#one_errback(*vs) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/em-dextras/chains.rb', line 26 def one_errback(*vs) deferrable, *values = vs @results[deferrable] = :error @errback_values.push *values check_if_complete end |