Module: SimpleStateMachine::MongoMapper::ClassMethods
- Defined in:
- lib/simple_state_machine/mongo_mapper.rb
Instance Method Summary collapse
Instance Method Details
#state_machine(column, column_states) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_state_machine/mongo_mapper.rb', line 13 def state_machine(column, column_states) states[column.to_sym] = column_states key column, String validates_inclusion_of column, :in => column_states define_method :"#{column}_revert" do write_key column, new? ? states[column].first : send(:"#{column}_was") end # define a method {state_column}_{state}? for each state column_states.each do |state| define_method :"#{column}_#{state}?" do send(column) === state end end end |