From bafbe77fb5edfa0579aef8adb6a18d9b76adf42f Mon Sep 17 00:00:00 2001 From: Scott Barron Date: Sat, 31 May 2008 15:37:22 -0700 Subject: [PATCH] SM support events instance methods consistently use self.class.aasm_ rather than going through SMFactory --- lib/aasm.rb | 10 ++++++---- lib/state_machine.rb | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/aasm.rb b/lib/aasm.rb index fc1b7bd..3cf2ecb 100644 --- a/lib/aasm.rb +++ b/lib/aasm.rb @@ -37,8 +37,10 @@ module AASM end def aasm_event(name, options = {}, &block) - unless aasm_events.has_key?(name) - aasm_events[name] = AASM::SupportingClasses::Event.new(name, options, &block) + sm = AASM::StateMachineFactory[self] + + unless sm.events.has_key?(name) + sm.events[name] = AASM::SupportingClasses::Event.new(name, options, &block) end define_method("#{name.to_s}!") do @@ -55,7 +57,7 @@ module AASM end def aasm_events - @aasm_events ||= {} + AASM::StateMachineFactory[self].events end def aasm_states_for_select @@ -100,7 +102,7 @@ module AASM end def aasm_state_object_for_state(name) - AASM::StateMachineFactory[self.class].states.find {|s| s == name} + self.class.aasm_states.find {|s| s == name} end def aasm_fire_event(name, persist) diff --git a/lib/state_machine.rb b/lib/state_machine.rb index b878735..4babaaa 100644 --- a/lib/state_machine.rb +++ b/lib/state_machine.rb @@ -11,7 +11,7 @@ module AASM @name = name @initial_state = nil @states = [] - @events = [] + @events = {} end def create_state(name, options)