Module: Mongoid::StateMachine::ActMacro
- Defined in:
- lib/mongoid/state_machine.rb
Instance Method Summary collapse
-
#state_machine(options = {}) ⇒ Object
Configuration options are.
Instance Method Details
#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)
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/mongoid/state_machine.rb', line 116 def 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 |