Class: State
- Inherits:
-
Object
- Object
- State
- Includes:
- DataMapper::Resource
- Defined in:
- lib/dm-is-persistent_state_machine/is/persistent_state_machine.rb
Instance Method Summary collapse
- #events ⇒ Object
-
#trigger_event!(obj, event_code) ⇒ Object
obj is the caller object.
Instance Method Details
#events ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/dm-is-persistent_state_machine/is/persistent_state_machine.rb', line 28 def events evts = [] state_transitions.each do |transition| # uses the generic event method evts << transition.state_event end evts end |
#trigger_event!(obj, event_code) ⇒ Object
obj is the caller object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dm-is-persistent_state_machine/is/persistent_state_machine.rb', line 38 def trigger_event!(obj, event_code) event = StateEvent.first(:code => event_code) state_transitions.each do |transition| if transition.state_event == event obj.state = transition.target obj.after_trigger_event(event) return true end end return false end |