1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/lib/state.rb
2008-05-31 15:11:18 -07:00

33 lines
646 B
Ruby

module AASM
module SupportingClasses
class State
attr_reader :name, :options
def initialize(name, options={})
@name, @options = name, options
end
def ==(state)
if state.is_a? Symbol
name == state
else
name == state.name
end
end
def call_action(action, record)
action = @options[action]
case action
when Symbol, String
record.send(action)
when Proc
action.call(record)
end
end
def for_select
[name.to_s.gsub(/_/, ' ').capitalize, name.to_s]
end
end
end
end