lib/statemachine/transition.rb in MINT-statemachine-1.3.0 vs lib/statemachine/transition.rb in MINT-statemachine-1.3.2
- old
+ new
@@ -56,25 +56,29 @@
sm = sm.is_parallel.statemachine
end
sm.activation.call(new_states,sm.abstract_states,sm.states_id) if sm.activation # and not @statemachine.is_parallel
end
- # Take any valid spontaneous transitions
- transition = destination.spontaneous_transition
+ # Take any valid spontaneous transitions for entered states
+ new_states.each do |entered_state|
+ s = statemachine.get_state(entered_state)
+ transition = s.spontaneous_transition
+ perform_spontaneous_transition(statemachine,s,transition,args) if transition and transition.length >0
+ end
+ end
- if transition
- if destination.is_parallel
- transition.each do |trans,statem|
- trans.each do |t|
- t[0].invoke(t[1], statem, args) if t[0].is_a? Transition
- end
+ def perform_spontaneous_transition(statemachine,destination,transition,args)
+ if destination.is_parallel
+ transition.each do |trans,statem|
+ trans.each do |t|
+ t[0].invoke(t[1], statem, args) if t[0].is_a? Transition
end
- else
+ end
+ else
- if transition.is_a? Array
- transition.each do |t|
- t[0].invoke(t[1], statemachine, args) if t[0].is_a? Transition
- end
+ if transition.is_a? Array
+ transition.each do |t|
+ t[0].invoke(t[1], statemachine, args) if t[0].is_a? Transition
end
end
end
end
\ No newline at end of file