Class: NxtStateMachine::Transition::AroundCallbackChain
- Inherits:
-
Object
- Object
- NxtStateMachine::Transition::AroundCallbackChain
- Defined in:
- lib/nxt_state_machine/transition/around_callback_chain.rb
Instance Method Summary collapse
- #build(proxy) ⇒ Object
-
#initialize(transition, context, state_machine) ⇒ AroundCallbackChain
constructor
A new instance of AroundCallbackChain.
Constructor Details
#initialize(transition, context, state_machine) ⇒ AroundCallbackChain
Returns a new instance of AroundCallbackChain.
4 5 6 7 8 |
# File 'lib/nxt_state_machine/transition/around_callback_chain.rb', line 4 def initialize(transition, context, state_machine) @transition = transition @context = context @state_machine = state_machine end |
Instance Method Details
#build(proxy) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/nxt_state_machine/transition/around_callback_chain.rb', line 10 def build(proxy) return proxy unless callbacks.any? callbacks.map { |c| Callable.new(c).bind(context) }.reverse.inject(proxy) do |previous, callback| -> { callback.call(previous, transition) } end end |