Module: CanHasState::Machine::ClassMethods
- Defined in:
- lib/can_has_state/machine.rb
Instance Method Summary collapse
Instance Method Details
#extend_state_machine(column, &block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/can_has_state/machine.rb', line 17 def extend_state_machine(column, &block) sm = state_machines.detect{|(col, _)| col == column} # |(col, stm)| raise(ArgumentError, "Unknown state machine #{column}") unless sm sm[1].extend_machine(&block) sm end |
#state_machine(column, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/can_has_state/machine.rb', line 7 def state_machine(column, &block) d = Definition.new(column, self, &block) define_method "allow_#{column}?" do |to| state_machine_allow?(column.to_sym, to.to_s) end self.state_machines += [[column.to_sym, d]] end |