mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
29 lines
699 B
Ruby
29 lines
699 B
Ruby
module AASM
|
|
module SupportingClasses
|
|
class State
|
|
attr_reader :name, :options
|
|
|
|
def initialize(name, options={})
|
|
@name, @options = name, options
|
|
end
|
|
|
|
def entering(record)
|
|
enteract = @options[:enter]
|
|
record.send(:run_transition_action, enteract) if enteract
|
|
end
|
|
|
|
def entered(record)
|
|
afteractions = @options[:after]
|
|
return unless afteractions
|
|
Array(afteractions).each do |afteract|
|
|
record.send(:run_transition_action, afteract)
|
|
end
|
|
end
|
|
|
|
def exited(record)
|
|
exitact = @options[:exit]
|
|
record.send(:run_transition_action, exitact) if exitact
|
|
end
|
|
end
|
|
end
|
|
end
|