From aad5a30bf25d8a3167afd685fc91c99f4f09cc57 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 4 Aug 2009 11:03:57 -0500 Subject: Add simple support for ActiveModel's StateMachine for ActiveRecord --- .../lib/active_model/state_machine/machine.rb | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'activemodel/lib/active_model/state_machine/machine.rb') diff --git a/activemodel/lib/active_model/state_machine/machine.rb b/activemodel/lib/active_model/state_machine/machine.rb index a5ede021b1..777531213e 100644 --- a/activemodel/lib/active_model/state_machine/machine.rb +++ b/activemodel/lib/active_model/state_machine/machine.rb @@ -1,6 +1,3 @@ -require 'active_model/state_machine/state' -require 'active_model/state_machine/event' - module ActiveModel module StateMachine class Machine @@ -57,22 +54,22 @@ module ActiveModel "@#{@name}_current_state" end - private - def state(name, options = {}) - @states << (state_index[name] ||= State.new(name, :machine => self)).update(options) - end + private + def state(name, options = {}) + @states << (state_index[name] ||= State.new(name, :machine => self)).update(options) + end - def event(name, options = {}, &block) - (@events[name] ||= Event.new(self, name)).update(options, &block) - end + def event(name, options = {}, &block) + (@events[name] ||= Event.new(self, name)).update(options, &block) + end - def event_fired_callback - @event_fired_callback ||= (@name == :default ? '' : "#{@name}_") + 'event_fired' - end + def event_fired_callback + @event_fired_callback ||= (@name == :default ? '' : "#{@name}_") + 'event_fired' + end - def event_failed_callback - @event_failed_callback ||= (@name == :default ? '' : "#{@name}_") + 'event_failed' - end + def event_failed_callback + @event_failed_callback ||= (@name == :default ? '' : "#{@name}_") + 'event_failed' + end end end end -- cgit v1.2.3