1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Some performance goodness for AM StateMatchine.

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
Clemens Kofler 2008-09-02 10:54:04 +02:00 committed by Jeremy Kemper
parent 948ed34600
commit b42f53ca1f

View file

@ -2,15 +2,15 @@ module ActiveModel
module StateMachine
class Event
attr_reader :name, :success
def initialize(machine, name, options = {}, &block)
@machine, @name, @transitions = machine, name, []
if machine
machine.klass.send(:define_method, "#{name.to_s}!") do |*args|
machine.klass.send(:define_method, "#{name}!") do |*args|
machine.fire_event(name, self, true, *args)
end
machine.klass.send(:define_method, "#{name.to_s}") do |*args|
machine.klass.send(:define_method, name.to_s) do |*args|
machine.fire_event(name, self, false, *args)
end
end