diff options
Diffstat (limited to 'activemodel/lib/active_model/state_machine')
-rw-r--r-- | activemodel/lib/active_model/state_machine/event.rb | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/state_machine/machine.rb | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/state_machine/event.rb b/activemodel/lib/active_model/state_machine/event.rb index ea4df343de..e8bc8ebdb7 100644 --- a/activemodel/lib/active_model/state_machine/event.rb +++ b/activemodel/lib/active_model/state_machine/event.rb @@ -37,10 +37,6 @@ module ActiveModel @transitions.any? { |t| t.from? state } end - def success? - !!@success - end - def ==(event) if event.is_a? Symbol name == event diff --git a/activemodel/lib/active_model/state_machine/machine.rb b/activemodel/lib/active_model/state_machine/machine.rb index 53ce71794f..170505c0b2 100644 --- a/activemodel/lib/active_model/state_machine/machine.rb +++ b/activemodel/lib/active_model/state_machine/machine.rb @@ -28,7 +28,9 @@ module ActiveModel record.send(event_fired_callback, record.current_state, new_state) end - record.current_state(@name, new_state) + record.current_state(@name, new_state, persist) + record.send(@events[event].success) if @events[event].success + true else if record.respond_to?(event_failed_callback) record.send(event_failed_callback, event) @@ -47,6 +49,10 @@ module ActiveModel events.map! { |event| event.name } end + def current_state_variable + "@#{@name}_current_state" + end + private def state(name, options = {}) @states << (state_index[name] ||= State.new(name, :machine => self)).update(options) |