Permalink
Browse files

Moved the save to the end of the state method, to allow modification …

…of the model in the enter new state hook
  • Loading branch information...
1 parent b854837 commit ac5f20d608e4b08f27e3b892235d4469f2c39b9f Ryan Oberholzer committed Dec 9, 2010
Showing with 6 additions and 6 deletions.
  1. +4 −4 examples/robot.rb
  2. +2 −2 lib/stateflow/event.rb
View
@@ -3,16 +3,16 @@
class Robot
include Stateflow
-
+
stateflow do
initial :green
-
+
state :green, :yellow, :red
-
+
event :change_color do
transitions :from => :green, :to => :yellow
transitions :from => :yellow, :to => :red
transitions :from => :red, :to => :green
end
end
-end
+end
@@ -20,10 +20,10 @@ def fire(current_state, klass, options)
raise NoStateFound.new("Invalid state #{transition.to.to_s} for transition.") if new_state.nil?
current_state.execute_action(:exit, klass)
- klass.set_current_state(new_state, options)
-
klass._previous_state = current_state.name.to_s
new_state.execute_action(:enter, klass)
+
+ klass.set_current_state(new_state, options)
true
end

0 comments on commit ac5f20d

Please sign in to comment.