module CanHasState::Machine::ClassMethods

Public Instance Methods

extend_state_machine(column, &block) click to toggle source
# 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) click to toggle source
# 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