Module: StatefulController
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/stateful_controller.rb,
lib/stateful_controller/version.rb
Defined Under Namespace
Classes: State
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
-
#next ⇒ Object
StatefulController always defines a special action called ‘next’ that goes to the next available transition.
-
#start ⇒ Object
SC also has a special action called “start” which clears state and reloads it (defaulting back to the initial state).
Instance Method Details
#next ⇒ Object
StatefulController always defines a special action called ‘next’ that goes to the next available transition.
41 42 43 44 45 46 47 48 |
# File 'lib/stateful_controller.rb', line 41 def next # this may rely on events having exactly one transition... otherwise, we may need an argument? (TBD) next_events = aasm.events(permitted: true).map(&:name) __debug("choosing first from next events: #{next_events.inspect}") next_event = next_events.first __process(next_event) self.send(next_event) end |
#start ⇒ Object
SC also has a special action called “start” which clears state and reloads it (defaulting back to the initial state)
51 52 53 54 |
# File 'lib/stateful_controller.rb', line 51 def start save_state(nil) __load end |