Module: RhodeIsland::ActiveRecordExtensions::ClassMethods
- Defined in:
- lib/rhode_island/active_record_extensions.rb
Instance Method Summary collapse
Instance Method Details
#has_state_machine(states) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rhode_island/active_record_extensions.rb', line 9 def has_state_machine(states) send :include, InstanceMethods class_eval do states.each do |state| define_method :"is_#{state}?" do self.state == state.to_s end unless self.respond_to?(:"is_#{state}?") define_method :"make_#{state}" do self.make(state) end define_method :"make_#{state}!" do self.make!(state) end end end end |