trailblazer-operation 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2bed59ccc4a6af470ef0413dfd4c5132c138a2ed68e1e7ed390ea7637c8db4e
4
- data.tar.gz: '074982e69ce025d63cc256964b8c334ad6405f792357201778beea2694668f93'
3
+ metadata.gz: 3c9a1ed221f6890d00d284c9a183e5082c1611cbcfc1cf9b37ec07dc09653258
4
+ data.tar.gz: 186a35a1414ee1d97f76d4950732272e1e171b6a89fa265a07e529686b35b27a
5
5
  SHA512:
6
- metadata.gz: 9b74fd06391e9035c5a82ff85b281e4b87445f18b0c238d5f939dfdb80e4541cd484743523a474371dfa2dd803068c6bb415732a40bea25dfa67fd777134dc3c
7
- data.tar.gz: 79eb31f4211e4a6521c3c06f879df49bf32b57f5b020b0f3a4273efb8c12fc047812f9a75f0987034c78fc6952945d5e4e24d08ac820b6c31222657490d4ea68
6
+ metadata.gz: f914f13cd0f1126c386026b62605a99c32126d7add2b917e685a14d76344b0ab9882d4727f3d6ec42550910b8b4507fac1b0b491315d067c6b5caddba4f06df6
7
+ data.tar.gz: 3b70bd25571a44f791a6d693d94c67156310741642769c84948310a291be905048fd7ce099a4769f648e9fa6c98276afbe82941291e40fbea5a663676e3d6831
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.7.4
2
+
3
+ * Fix `Operation.call` being called twice before delegating to `call_with_circuit_interface`. This is done via a special `call_task` in the operation's taskWrap.
4
+
1
5
  ## 0.7.3
2
6
 
3
7
  * Revert trailblazer-developer to a runtime dependency.
@@ -47,7 +47,7 @@ module Trailblazer
47
47
  end
48
48
 
49
49
  require "trailblazer/operation/public_call" # TODO: Remove in 3.0.
50
- extend PublicCall # ::call(params, { current_user: .. })
50
+ extend PublicCall # ::call(params: .., current_user: ..)
51
51
 
52
52
  require "trailblazer/operation/trace"
53
53
  extend Trace # ::trace
@@ -14,7 +14,7 @@ module Trailblazer
14
14
  # @note Do not override this method as it will be removed in future versions. Also, you will break tracing.
15
15
  # @return Operation::Railway::Result binary result object
16
16
  def call(options = {}, flow_options = {}, **circuit_options)
17
- return call_with_circuit_interface(options, **circuit_options) if options.is_a?(Array) # This is kind of a hack that could be well hidden if Ruby had method overloading. Goal is to simplify the call/__call__ thing as we're fading out Operation::call anyway.
17
+ return call_with_circuit_interface(options, **circuit_options) if options.is_a?(Array) # This is kind of a hack that could be well hidden if Ruby had method overloading. Goal is to simplify the call thing as we're fading out Operation::public_call anyway.
18
18
 
19
19
  call_with_public_interface(options, flow_options, **circuit_options)
20
20
  end
@@ -40,7 +40,8 @@ module Trailblazer
40
40
  signal, (ctx, flow_options) = invoke_class.invoke(
41
41
  self,
42
42
  [ctx, flow_options],
43
- exec_context: new
43
+ exec_context: new,
44
+ wrap_static: initial_wrap_static,
44
45
  )
45
46
 
46
47
  # Result is successful if the activity ended with an End event derived from Railway::End::Success.
@@ -79,5 +80,24 @@ module Trailblazer
79
80
  raise "[Trailblazer] `Operation.call_with_flow_options is deprecated in Ruby 3.0. Use `Operation.(options, flow_options)`" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")
80
81
  call_with_public_interface(options, flow_options, {invoke_class: Activity::TaskWrap})
81
82
  end
83
+
84
+ def initial_wrap_static(*)
85
+ Activity::TaskWrap::Pipeline.new([["task_wrap.call_task", method(:call_task)]])
86
+ end
87
+
88
+ def call_task(wrap_ctx, original_args) # DISCUSS: copied from {TaskWrap.call_task}.
89
+ op = wrap_ctx[:task]
90
+
91
+ original_arguments, original_circuit_options = original_args
92
+
93
+ # Call the actual task we're wrapping here.
94
+ # puts "~~~~wrap.call: #{task}"
95
+ return_signal, return_args = op.call_with_circuit_interface(original_arguments, **original_circuit_options)
96
+
97
+ # DISCUSS: do we want original_args here to be passed on, or the "effective" return_args which are different to original_args now?
98
+ wrap_ctx = wrap_ctx.merge(return_signal: return_signal, return_args: return_args)
99
+
100
+ return wrap_ctx, original_args
101
+ end
82
102
  end
83
103
  end
@@ -1,7 +1,7 @@
1
1
  module Trailblazer
2
2
  module Version
3
3
  module Operation
4
- VERSION = "0.7.3"
4
+ VERSION = "0.7.4"
5
5
  end
6
6
  end
7
7
  end
@@ -1,6 +1,28 @@
1
1
  require "test_helper"
2
2
 
3
3
  class DeclarativeApiTest < Minitest::Spec
4
+ it "doesn't invoke {call} twice when using public interface" do
5
+ class MyOp < Trailblazer::Operation
6
+ @@GLOBAL = []
7
+ def self.global; @@GLOBAL; end
8
+
9
+
10
+ def self.call(*args)
11
+ @@GLOBAL << :call
12
+ super
13
+ end
14
+
15
+ pass :model
16
+
17
+ def model(ctx, **)
18
+ @@GLOBAL << :model
19
+ end
20
+ end
21
+
22
+ MyOp.({})
23
+ MyOp.global.inspect.must_equal %{[:call, :model]}
24
+ end
25
+
4
26
  #---
5
27
  #- step, pass, fail
6
28
 
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "trailblazer-activity-dsl-linear", ">= 0.4.0", "< 1.0.0"
21
+ spec.add_dependency "trailblazer-activity", ">= 0.12.1", "< 1.0.0"
21
22
  spec.add_dependency "trailblazer-developer", ">= 0.0.21", "< 1.0.0"
22
23
 
23
24
  spec.add_development_dependency "bundler"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-12 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-activity-dsl-linear
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: trailblazer-activity
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.12.1
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 1.0.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.12.1
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 1.0.0
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: trailblazer-developer
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +181,7 @@ homepage: http://trailblazer.to
161
181
  licenses:
162
182
  - MIT
163
183
  metadata: {}
164
- post_install_message:
184
+ post_install_message:
165
185
  rdoc_options: []
166
186
  require_paths:
167
187
  - lib
@@ -177,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
197
  version: '0'
178
198
  requirements: []
179
199
  rubygems_version: 3.0.8
180
- signing_key:
200
+ signing_key:
181
201
  specification_version: 4
182
202
  summary: Trailblazer's operation object with railway flow and integrated error handling.
183
203
  test_files: