class StateMachine::AttributeTransitionCollection
Represents a collection of transitions that were generated from attribute- based events
Private Instance Methods
persist()
click to toggle source
Tracks that before callbacks have now completed
Calls superclass method
StateMachine::TransitionCollection#persist
# File lib/state_machine/transition_collection.rb, line 228 def persist @before_run = true super end
reset()
click to toggle source
Resets callback tracking
Calls superclass method
StateMachine::TransitionCollection#reset
# File lib/state_machine/transition_collection.rb, line 234 def reset super @before_run = false end
rollback()
click to toggle source
Resets the event attribute so it can be re-evaluated if attempted again
Calls superclass method
StateMachine::TransitionCollection#rollback
# File lib/state_machine/transition_collection.rb, line 240 def rollback super each {|transition| transition.machine.write(object, :event, transition.event) unless transition.transient?} end
run_callbacks(index = 0)
click to toggle source
Hooks into running transition callbacks so that event / event transition attributes can be properly updated
Calls superclass method
StateMachine::TransitionCollection#run_callbacks
# File lib/state_machine/transition_collection.rb, line 201 def run_callbacks(index = 0) if index == 0 # Clears any traces of the event attribute to prevent it from being # evaluated multiple times if actions are nested each do |transition| transition.machine.write(object, :event, nil) transition.machine.write(object, :event_transition, nil) end # Rollback only if exceptions occur during before callbacks begin super rescue Exception rollback unless @before_run raise end # Persists transitions on the object if partial transition was successful. # This allows us to reference them later to complete the transition with # after callbacks. each {|transition| transition.machine.write(object, :event_transition, transition)} if skip_after && success? else super end end