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:
parent
948ed34600
commit
b42f53ca1f
1 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue