Module: ScottBarron::Acts::StateMachine::ActMacro
- Defined in:
- lib/acts_as_state_machine.rb
Instance Method Summary collapse
-
#acts_as_state_machine(options = {}) ⇒ Object
Configuration options are.
Instance Method Details
#acts_as_state_machine(options = {}) ⇒ Object
Configuration options are
-
column
- specifies the column name to use for keeping the state (default: state) -
initial
- specifies an initial state for newly created objects (required)
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/acts_as_state_machine.rb', line 114 def acts_as_state_machine( = {}) class_eval do extend ClassMethods include InstanceMethods raise NoInitialState unless [:initial] write_inheritable_attribute :states, {} write_inheritable_attribute :initial_state, [:initial] write_inheritable_attribute :transition_table, {} write_inheritable_attribute :event_table, {} write_inheritable_attribute :state_column, [:column] || 'state' class_inheritable_reader :initial_state class_inheritable_reader :state_column class_inheritable_reader :transition_table class_inheritable_reader :event_table before_create :set_initial_state after_create :run_initial_state_actions end end |