module Ably::Modules::StatesmanMonkeyPatch

@api private

Public Instance Methods

after_transition(options = nil, &block) click to toggle source

Override Statesman’s after_transition to support :from arrays This can be removed once github.com/gocardless/statesman/issues/95 is solved

Calls superclass method
# File lib/submodules/ably-ruby/lib/ably/modules/statesman_monkey_patch.rb, line 14
def after_transition(options = nil, &block)
  arrayify_transition(options) do |options_without_from_array|
    super(*options_without_from_array, &block)
  end
end
before_transition(options = nil, &block) click to toggle source

Override Statesman’s before_transition to support :from arrays This can be removed once github.com/gocardless/statesman/issues/95 is solved

Calls superclass method
# File lib/submodules/ably-ruby/lib/ably/modules/statesman_monkey_patch.rb, line 6
def before_transition(options = nil, &block)
  arrayify_transition(options) do |options_without_from_array|
    super(*options_without_from_array, &block)
  end
end

Private Instance Methods

arrayify_transition(options) { || ... } click to toggle source
# File lib/submodules/ably-ruby/lib/ably/modules/statesman_monkey_patch.rb, line 21
def arrayify_transition(options, &block)
  if options.nil?
    yield []
  elsif options.fetch(:from, nil).kind_of?(Array)
    options[:from].each do |from_state|
      yield [options.merge(from: from_state)]
    end
  else
    yield [options]
  end
end