Module: Workflow::WorkflowInstanceMethods
- Defined in:
- lib/workflow.rb
Instance Method Summary collapse
- #current_state ⇒ Object
- #halted? ⇒ Boolean
- #halted_because ⇒ Object
- #process_event!(name, *args) ⇒ Object
Instance Method Details
#current_state ⇒ Object
111 112 113 114 115 |
# File 'lib/workflow.rb', line 111 def current_state loaded_state = load_workflow_state res = spec.states[loaded_state.to_sym] if loaded_state res || spec.initial_state end |
#halted? ⇒ Boolean
117 118 119 |
# File 'lib/workflow.rb', line 117 def halted? @halted end |
#halted_because ⇒ Object
121 122 123 |
# File 'lib/workflow.rb', line 121 def halted_because @halted_because end |
#process_event!(name, *args) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/workflow.rb', line 125 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? @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 TransitionHalted.new(@halted_because) else false end else run_on_transition(current_state, spec.states[event.transitions_to], name, *args) transition(current_state, spec.states[event.transitions_to], name, *args) return_value end end |