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

30 lines
699 B
Ruby
Raw Normal View History

2008-01-07 14:11:38 -05:00
module AASM
module SupportingClasses
class State
attr_reader :name, :options
2008-01-07 14:11:38 -05:00
def initialize(name, options={})
@name, @options = name, options
2008-01-07 14:11:38 -05:00
end
def entering(record)
enteract = @options[:enter]
2008-01-07 14:11:38 -05:00
record.send(:run_transition_action, enteract) if enteract
end
def entered(record)
afteractions = @options[:after]
2008-01-07 14:11:38 -05:00
return unless afteractions
Array(afteractions).each do |afteract|
record.send(:run_transition_action, afteract)
end
end
def exited(record)
exitact = @options[:exit]
2008-01-07 14:11:38 -05:00
record.send(:run_transition_action, exitact) if exitact
end
end
end
end