Module: ActionOperation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/action_operation.rb,
lib/action_operation/error.rb,
lib/action_operation/types.rb,
lib/action_operation/version.rb,
lib/action_operation/error/missing_task.rb,
lib/action_operation/error/missing_error.rb,
lib/action_operation/error/missing_schema.rb,
lib/action_operation/error/step_schema_mismatch.rb
Defined Under Namespace
Modules: Types
Classes: Catch, Drift, Error, State, Task
Constant Summary
collapse
- VERSION =
"2.2.0"
Instance Method Summary
collapse
-
#around_catch(exception:, raw:, step:, &callback) ⇒ Object
-
#around_catches(exception:, raw:, &callback) ⇒ Object
-
#around_step(state: nil, exception: nil, raw:, step:, &callback) ⇒ Object
-
#around_steps(raw:, &callback) ⇒ Object
-
#around_task(state:, raw:, step:, &callback) ⇒ Object
-
#around_tasks(raw:, &callback) ⇒ Object
-
#call(start: nil, raw: @raw) ⇒ Object
-
#drift(to:) ⇒ Object
-
#fresh(state:) ⇒ Object
-
#initialize(raw:) ⇒ Object
-
#reraise(exception:) ⇒ Object
Instance Method Details
#around_catch(exception:, raw:, step:, &callback) ⇒ Object
127
128
129
|
# File 'lib/action_operation.rb', line 127
def around_catch(exception:, raw:, step:, &callback)
callback.call(exception: exception, raw: raw, step: step)
end
|
#around_catches(exception:, raw:, &callback) ⇒ Object
123
124
125
|
# File 'lib/action_operation.rb', line 123
def around_catches(exception:, raw:, &callback)
callback.call(exception: exception, raw: raw)
end
|
#around_step(state: nil, exception: nil, raw:, step:, &callback) ⇒ Object
111
112
113
|
# File 'lib/action_operation.rb', line 111
def around_step(state: nil, exception: nil, raw:, step:, &callback)
callback.call(state: state, exception: exception, raw: raw, step: step)
end
|
#around_steps(raw:, &callback) ⇒ Object
107
108
109
|
# File 'lib/action_operation.rb', line 107
def around_steps(raw:, &callback)
callback.call(raw: raw)
end
|
#around_task(state:, raw:, step:, &callback) ⇒ Object
119
120
121
|
# File 'lib/action_operation.rb', line 119
def around_task(state:, raw:, step:, &callback)
callback.call(state: state, raw: raw, step: step)
end
|
#around_tasks(raw:, &callback) ⇒ Object
115
116
117
|
# File 'lib/action_operation.rb', line 115
def around_tasks(raw:, &callback)
callback.call(raw: raw)
end
|
#call(start: nil, raw: @raw) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/action_operation.rb', line 23
def call(start: nil, raw: @raw)
around_steps(raw: raw) do
begin
around_tasks(raw: raw) do
tasks(start, raw)
end
rescue *left.select(&:exception).map(&:exception).uniq => handled_exception
around_catches(exception: handled_exception, raw: raw) do
catches(handled_exception, raw)
end
end
end
end
|
#drift(to:) ⇒ Object
101
102
103
104
105
|
# File 'lib/action_operation.rb', line 101
def drift(to:)
raise ArgumentError, "needs to be a Symbol or String" unless to.kind_of?(Symbol) || to.kind_of?(String)
Drift.new(to)
end
|
#fresh(state:) ⇒ Object
95
96
97
98
99
|
# File 'lib/action_operation.rb', line 95
def fresh(state:)
raise ArgumentError, "needs to be a Hash" unless state.kind_of?(Hash)
State.new(state)
end
|
#initialize(raw:) ⇒ Object
17
18
19
20
21
|
# File 'lib/action_operation.rb', line 17
def initialize(raw:)
raise ArgumentError, "needs to be a Hash" unless raw.kind_of?(Hash)
@raw = raw
end
|
#reraise(exception:) ⇒ Object
139
140
141
|
# File 'lib/action_operation.rb', line 139
def reraise(exception:, **)
raise exception
end
|