Permalink
Browse files

Revert "Revert "Add write_state_without_persistence implementation""

This reverts commit eff0d85.
  • Loading branch information...
1 parent f1d08e7 commit a6345c1bfe4b939f7b4312c352f5d52300db2841 @troessner troessner committed May 2, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/active_model/transitions.rb
@@ -45,16 +45,19 @@ def reload(options = nil)
protected
def write_state(state_machine, state)
- ivar = state_machine.current_state_variable
prev_state = current_state(state_machine.name)
- instance_variable_set(ivar, state)
- self.state = state.to_s
+ write_state_without_persistence(state_machine, state)
save!
rescue ActiveRecord::RecordInvalid
- self.state = prev_state.to_s
- instance_variable_set(ivar, prev_state)
+ write_state_without_persistence(state_machine, prev_state)
raise
end
+
+ def write_state_without_persistence(state_machine, state)
+ ivar = state_machine.current_state_variable
+ instance_variable_set(ivar, state)
+ self.state = state.to_s
+ end
def read_state(state_machine)
self.state && self.state.to_sym

0 comments on commit a6345c1

Please sign in to comment.