1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

SM support events

instance methods consistently use self.class.aasm_ rather than going through SMFactory
This commit is contained in:
Scott Barron 2008-05-31 15:37:22 -07:00
parent cf2bd90cfb
commit bafbe77fb5
2 changed files with 7 additions and 5 deletions

View file

@ -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)

View file

@ -11,7 +11,7 @@ module AASM
@name = name
@initial_state = nil
@states = []
@events = []
@events = {}
end
def create_state(name, options)