action_operation 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/action_operation.rb +20 -16
- data/lib/action_operation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a846d65438bef6ffc0ab9fc92d244eddbedd899fc55e93047b87753e3fb4b8cc
|
4
|
+
data.tar.gz: ecadc2048e631a532ef3e44a0b777f936de0801f578ab067958de662b793533f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8299c5b881d42659982fd058c5dc0fabede4a262eee74380a09fa35677a6fdc5b3aad9b7fea7ecfa13257d891cf7167b4d018ceb9c7afaa501b23ea41c22355
|
7
|
+
data.tar.gz: ee88c4f8d8ded7e7be2b6fd745786b9bfb01301422ef8566c1b9fa7bc125f6ea574364edd25456ae18b4fa29c958c1a9e2b01344928c10d58e24f6c3d00d7f9f
|
data/README.md
CHANGED
@@ -258,7 +258,7 @@ While `around_steps` is on the entire operation, you might want individual wrapp
|
|
258
258
|
|
259
259
|
``` ruby
|
260
260
|
class AddProductToCart < ApplicationOperation
|
261
|
-
def around_step(step
|
261
|
+
def around_step(step:, **)
|
262
262
|
Rails.logger.tagged("step-id=#{SecureRandom.uuid}") do
|
263
263
|
yield
|
264
264
|
end
|
@@ -273,13 +273,13 @@ Finally, there are 4 other type specific hooks: `around_tasks`, `around_task`, `
|
|
273
273
|
|
274
274
|
``` ruby
|
275
275
|
class AddProductToCart < ApplicationOperation
|
276
|
-
def around_tasks
|
276
|
+
def around_tasks(**)
|
277
277
|
Timeout.new(30.seconds) do
|
278
278
|
yield
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
282
|
-
def around_task(step:, state
|
282
|
+
def around_task(step:, state:, **)
|
283
283
|
Rails.logger.debug("Working on #{step.receiver}##{step.name} using (#{state.to_json})")
|
284
284
|
|
285
285
|
Timeout.new(10.seconds) do
|
@@ -296,7 +296,7 @@ end
|
|
296
296
|
|
297
297
|
Add this line to your application's Gemfile:
|
298
298
|
|
299
|
-
gem "action_operation", "2.1.
|
299
|
+
gem "action_operation", "2.1.2"
|
300
300
|
|
301
301
|
And then execute:
|
302
302
|
|
data/lib/action_operation.rb
CHANGED
@@ -47,8 +47,10 @@ module ActionOperation
|
|
47
47
|
# puts "#{step.class}::#{step.receiver}##{step.name}"
|
48
48
|
|
49
49
|
begin
|
50
|
-
value =
|
51
|
-
|
50
|
+
value = around_step(state: self.class.schemas.fetch(step.name).new(state), raw: raw, step: step) do
|
51
|
+
around_task(state: self.class.schemas.fetch(step.name).new(state), raw: raw, step: step) do
|
52
|
+
public_send(step.name, state: self.class.schemas.fetch(step.name).new(state))
|
53
|
+
end
|
52
54
|
end
|
53
55
|
# puts "#{step.class}::#{step.receiver}##{step.name} #{value}"
|
54
56
|
rescue SmartParams::Error::InvalidPropertyType => invalid_property_type_exception
|
@@ -72,8 +74,10 @@ module ActionOperation
|
|
72
74
|
# puts "#{step.class}::#{step.receiver}##{step.name}"
|
73
75
|
|
74
76
|
begin
|
75
|
-
value =
|
76
|
-
|
77
|
+
value = around_step(exception: exception, raw: raw, step: step) do
|
78
|
+
around_catch(exception: exception, raw: raw, step: step) do
|
79
|
+
public_send(step.name, exception: exception, state: raw, step: @latest_step)
|
80
|
+
end
|
77
81
|
end
|
78
82
|
# puts "#{step.class}::#{step.receiver}##{step.name} #{value}"
|
79
83
|
rescue SmartParams::Error::InvalidPropertyType => invalid_property_type_exception
|
@@ -100,28 +104,28 @@ module ActionOperation
|
|
100
104
|
Drift.new(to)
|
101
105
|
end
|
102
106
|
|
103
|
-
def around_steps(&callback)
|
104
|
-
callback.call
|
107
|
+
def around_steps(raw:, &callback)
|
108
|
+
callback.call(raw: raw)
|
105
109
|
end
|
106
110
|
|
107
|
-
def around_step(&callback)
|
108
|
-
callback.call
|
111
|
+
def around_step(state: nil, exception: nil, raw:, step:, &callback)
|
112
|
+
callback.call(state: state, exception: exception, raw: raw, step: step)
|
109
113
|
end
|
110
114
|
|
111
|
-
def around_tasks(&callback)
|
112
|
-
callback.call
|
115
|
+
def around_tasks(raw:, &callback)
|
116
|
+
callback.call(raw: raw)
|
113
117
|
end
|
114
118
|
|
115
|
-
def around_task(&callback)
|
116
|
-
callback.call
|
119
|
+
def around_task(state:, raw:, step:, &callback)
|
120
|
+
callback.call(state: state, raw: raw, step: step)
|
117
121
|
end
|
118
122
|
|
119
|
-
def around_catches(&callback)
|
120
|
-
callback.call
|
123
|
+
def around_catches(exception:, raw:, &callback)
|
124
|
+
callback.call(exception: exception, raw: raw)
|
121
125
|
end
|
122
126
|
|
123
|
-
def around_catch(&callback)
|
124
|
-
callback.call
|
127
|
+
def around_catch(exception:, raw:, step:, &callback)
|
128
|
+
callback.call(exception: exception, raw: raw, step: step)
|
125
129
|
end
|
126
130
|
|
127
131
|
private def left
|