Class: StateFlow::Action
- Includes:
- ActionClient, EventClient, GuardClient
- Defined in:
- lib/state_flow/action.rb
Instance Attribute Summary collapse
-
#method_args ⇒ Object
readonly
Returns the value of attribute method_args.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(origin, method_name, *method_args, &block) ⇒ Action
constructor
A new instance of Action.
- #process(context) ⇒ Object
Methods included from GuardClient
#guard, #guard_else, #guard_for, #guards
Methods included from EventClient
#action_event, #event, #event_else, #event_for_action_result, #events, #handle_exception, #named_event, #recover
Methods included from ExceptionHandlerClient
#exception_handlers, #exception_handling
Methods included from ActionClient
Methods inherited from Element
#flow, #inspect, #retry_in_recovering, #state, #to, uninspected_var, uninspected_vars, #update_to_destination
Methods included from ElementVisitable
Constructor Details
#initialize(origin, method_name, *method_args, &block) ⇒ Action
Returns a new instance of Action.
11 12 13 14 |
# File 'lib/state_flow/action.rb', line 11 def initialize(origin, method_name, *method_args, &block) @method_name, @method_args = method_name, method_args super(origin, &block) end |
Instance Attribute Details
#method_args ⇒ Object (readonly)
Returns the value of attribute method_args.
10 11 12 |
# File 'lib/state_flow/action.rb', line 10 def method_args @method_args end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
10 11 12 |
# File 'lib/state_flow/action.rb', line 10 def method_name @method_name end |
Instance Method Details
#process(context) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/state_flow/action.rb', line 16 def process(context) context.trace(self) context.mark_proceeding exception_handling(context) do result = context.record_send(method_name, *method_args) event = event_for_action_result(result) event.process(context) if event unless event action.process(context) if action end update_to_destination(context) end end |