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

34 lines
646 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 ==(state)
if state.is_a? Symbol
name == state
else
name == state.name
2008-01-07 14:11:38 -05:00
end
end
def call_action(action, record)
action = @options[action]
case action
when Symbol, String
record.send(action)
when Proc
action.call(record)
end
2008-01-07 14:11:38 -05:00
end
2008-05-31 18:11:18 -04:00
def for_select
[name.to_s.gsub(/_/, ' ').capitalize, name.to_s]
end
2008-01-07 14:11:38 -05:00
end
end
end