Module: Apollo::InstanceMethods
- Defined in:
- lib/apollo.rb
Instance Method Summary collapse
- #current_state ⇒ Object
- #current_state=(new_value) ⇒ Object
- #default_state ⇒ Object
- #halted? ⇒ Boolean
- #halted_because ⇒ Object
- #process_event!(name, *args) ⇒ Object
Instance Method Details
#current_state ⇒ Object
88 89 90 91 92 |
# File 'lib/apollo.rb', line 88 def current_state loaded_state = load_current_state res = spec.states[loaded_state.to_sym] if loaded_state res || spec.initial_state end |
#current_state=(new_value) ⇒ Object
94 95 96 |
# File 'lib/apollo.rb', line 94 def current_state=(new_value) @current_state = new_value.to_s end |
#default_state ⇒ Object
98 99 100 |
# File 'lib/apollo.rb', line 98 def default_state self.class.state_machine.default_state end |
#halted? ⇒ Boolean
102 103 104 |
# File 'lib/apollo.rb', line 102 def halted? @halted end |
#halted_because ⇒ Object
106 107 108 |
# File 'lib/apollo.rb', line 106 def halted_because @halted_because end |
#process_event!(name, *args) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/apollo.rb', line 110 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 |