lib/submodules/ably-ruby/lib/ably/modules/state_emitter.rb in ably-rest-0.8.5 vs lib/submodules/ably-ruby/lib/ably/modules/state_emitter.rb in ably-rest-0.8.6
- old
+ new
@@ -69,14 +69,14 @@
# @option options [Proc] :else block called once the state has changed to anything but target_state
#
# @yield block is called if the state is matched immediately or once when the state is reached
#
# @return [void]
- def once_or_if(target_states, options = {})
+ def once_or_if(target_states, options = {}, &block)
raise ArgumentError, 'Block required' unless block_given?
if Array(target_states).any? { |target_state| state == target_state }
- yield
+ safe_yield block
else
failure_block = options.fetch(:else, nil)
failure_wrapper = nil
success_wrapper = Proc.new do