Module: Apollo::InstanceMethods
- Defined in:
- lib/apollo.rb
Instance Method Summary collapse
- #current_state ⇒ Object
- #halted? ⇒ Boolean
- #halted_because ⇒ Object
- #process_event!(name, *args) ⇒ Object
Instance Method Details
#current_state ⇒ Object
86 87 88 89 90 |
# File 'lib/apollo.rb', line 86 def current_state loaded_state = load_current_state res = spec.states[loaded_state.to_sym] if loaded_state res || spec.initial_state end |
#halted? ⇒ Boolean
92 93 94 |
# File 'lib/apollo.rb', line 92 def halted? @halted end |
#halted_because ⇒ Object
96 97 98 |
# File 'lib/apollo.rb', line 96 def halted_because @halted_because end |
#process_event!(name, *args) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/apollo.rb', line 100 def process_event!(name, *args) event = current_state.events[name.to_sym] raise NoTransitionAllowed.new( "There is no event #{name.to_sym} defined for the #{current_state} state") \ if event.nil? # This three member variables are a relict from the old workflow library # TODO: refactor some day @halted_because = nil @halted = false @raise_exception_on_halt = false return_value = run_action(event.action, *args) || run_action_callback(event.name, *args) if @halted if @raise_exception_on_halt raise @raise_exception_on_halt else false end else check_transition(event) run_on_transition(current_state, spec.states[event.to], name, *args) transition(current_state, spec.states[event.to], name, *args) return_value end end |