trailblazer-operation 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c019f1fb62cb71a67f95393c340495f3cd512c7914dffae69b8a8789a41b0a5
4
- data.tar.gz: 79e8ef13bbc5193d66e5bd522e3991215f97b581c202bb8b78fde79e877e204e
3
+ metadata.gz: 00f1e4d05147c0c9434d2a72017c7ea452cd06a5bf5e90985f7f809f5246ac9b
4
+ data.tar.gz: 6508179d1158e4719f90e7e6a219676b47780468d99f58b6c4178f423415f6ca
5
5
  SHA512:
6
- metadata.gz: 26a554047293b40351fccc08b2f06877d142d6c1e81f6aa1cec0e51e6c4fb8f33f680cf90d5a35437b62e1eb3549d3504f45c601fcb707c2765e286e4de87ff9
7
- data.tar.gz: 30c55dd1a0d0edc75d4c1ff8bd5b66edb14250506eab46d9db090d1d4dbc35f8b0cd38d0abcdaa99d0f156578576461de281479014ac2028892ce31cefcdf519
6
+ metadata.gz: bc578ee53cf1f1ecbef264943841734cb250902c329f7866eec533553e720c58ac1d5f8edf3bf84405a138aa37f25a7abf01153458ce3d177833fe0e51f83801
7
+ data.tar.gz: b1972a63eddccb14fb5814c0e973543757feb56d62a0400be18da49ef8c0ca3ddda40aaef8d28983177783a48aa2345b8d86f4eaf52a43a098638956914ef60c
@@ -1,6 +1,3 @@
1
- ## This file is managed by Terraform.
2
- ## Do not modify this file directly, as it may be overwritten.
3
- ## Please open an issue instead.
4
1
  name: CI
5
2
  on: [push, pull_request]
6
3
  jobs:
@@ -8,7 +5,7 @@ jobs:
8
5
  strategy:
9
6
  fail-fast: false
10
7
  matrix:
11
- ruby: [2.7, '3.0', '3.1']
8
+ ruby: [2.5, 2.6, 2.7, '3.0', '3.1', '3.2', 'jruby']
12
9
  runs-on: ubuntu-latest
13
10
  steps:
14
11
  - uses: actions/checkout@v3
data/CHANGES.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 0.10.1
2
+
3
+ * Deprecate `Operation.trace` and `Result#wtf?` in favor of `Operation.wtf?`.
4
+ * Use `trailblazer-developer-0.1.0`.
5
+
6
+ ## 0.10.0
7
+
8
+ * Require `trailblazer-activity-dsl-linear-1.2.0`.
9
+ * Remove `Railway::Macaroni`.
10
+ * Remove `Operation::Callable`.
11
+ * Introduce `Operation::INITIAL_WRAP_STATIC` that is computed once at compile-time, not
12
+ with every `#call`.
13
+
1
14
  ## 0.9.0
2
15
 
3
16
  * Use `trailblazer-activity-dsl-linear` 1.1.0.
data/Gemfile CHANGED
@@ -3,16 +3,9 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in trailblazer.gemspec
4
4
  gemspec
5
5
 
6
- gem "multi_json"
6
+ # gem "trailblazer-developer", path: "../trailblazer-developer"
7
+ # gem "trailblazer-activity", path: "../trailblazer-activity"
8
+ # gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
7
9
 
8
- gem "dry-auto_inject"
9
-
10
- gem "benchmark-ips"
11
- gem "minitest-line"
12
-
13
- # gem "trailblazer-developer", path: "../trailblazer-developer"
14
- # gem "trailblazer-developer", git: "https://github.com/trailblazer/trailblazer-developer"
15
- # gem "trailblazer-activity", path: "../trailblazer-activity"
16
- # gem "trailblazer-context", path: "../trailblazer-context"
17
- # gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
18
- # gem "trailblazer-activity", github: "trailblazer/trailblazer-activity"
10
+ # gem "trailblazer-activity", github: "trailblazer/trailblazer-activity"
11
+ # gem "trailblazer-developer", github: "trailblazer/trailblazer-developer"
@@ -77,16 +77,14 @@ module Trailblazer
77
77
  end
78
78
 
79
79
  # TODO: remove when we stop supporting < 3.0.
80
+ # alternatively, ctx aliasing is only available for Ruby > 2.7.
80
81
  def call_with_flow_options(options, flow_options)
81
82
  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")
82
83
  call_with_public_interface(options, flow_options, {invoke_class: Activity::TaskWrap})
83
84
  end
84
85
 
85
- def initial_wrap_static(*)
86
- Activity::TaskWrap::Pipeline.new([Activity::TaskWrap::Pipeline.Row("task_wrap.call_task", method(:call_task))])
87
- end
88
-
89
- def call_task(wrap_ctx, original_args) # DISCUSS: copied from {TaskWrap.call_task}.
86
+ # @private
87
+ def self.call_task(wrap_ctx, original_args) # DISCUSS: copied from {TaskWrap.call_task}.
90
88
  op = wrap_ctx[:task]
91
89
 
92
90
  original_arguments, original_circuit_options = original_args
@@ -100,5 +98,11 @@ module Trailblazer
100
98
 
101
99
  return wrap_ctx, original_args
102
100
  end
101
+
102
+ INITIAL_WRAP_STATIC = Activity::TaskWrap::Pipeline.new([Activity::TaskWrap::Pipeline.Row("task_wrap.call_task", method(:call_task))])
103
+
104
+ def initial_wrap_static
105
+ INITIAL_WRAP_STATIC
106
+ end
103
107
  end
104
108
  end
@@ -1,4 +1,4 @@
1
- require 'delegate'
1
+ require "delegate"
2
2
  require "trailblazer/developer"
3
3
 
4
4
  module Trailblazer
@@ -13,7 +13,7 @@ module Trailblazer
13
13
 
14
14
  result = Railway::Result(signal, ctx) # redundant with PublicCall::call.
15
15
 
16
- Result.new(result, stack.to_a)
16
+ Result.new(result, stack)
17
17
  end
18
18
 
19
19
  # `Operation::trace` is included for simple tracing of the flow.
@@ -22,7 +22,11 @@ module Trailblazer
22
22
  # @public
23
23
  #
24
24
  # Operation.trace(params, current_user: current_user).wtf
25
+ # TODO: remove in 0.11.0.
25
26
  def trace(options)
27
+ Activity::Deprecate.warn Trace.find_caller_location_for_deprecated, %(Using `Operation.trace` is deprecated and will be removed in {trailblazer-operation-0.11.0}.
28
+ Please use `#{self}.wtf?` as documented here: https://trailblazer.to/2.1/docs/trailblazer#trailblazer-developer-wtf-)
29
+
26
30
  Trace.(self, options)
27
31
  end
28
32
 
@@ -30,6 +34,14 @@ module Trailblazer
30
34
  call_with_public_interface(options, {}, invoke_class: Developer::Wtf)
31
35
  end
32
36
 
37
+ # TODO: remove in 0.11.0.
38
+ def self.find_caller_location_for_deprecated
39
+ our_caller_locations = caller_locations.to_a
40
+ caller_location = our_caller_locations.reverse.find { |line| line.to_s =~ /operation\/trace/ }
41
+
42
+ _caller_location = our_caller_locations[our_caller_locations.index(caller_location)+1]
43
+ end
44
+
33
45
  # Presentation of the traced stack via the returned result object.
34
46
  # This object is wrapped around the original result in {Trace.call}.
35
47
  class Result < ::SimpleDelegator
@@ -38,12 +50,14 @@ module Trailblazer
38
50
  @stack = stack
39
51
  end
40
52
 
41
- # TODO: deprecate!
53
+ # TODO: remove in 0.11.0.
42
54
  def wtf
55
+ Activity::Deprecate.warn Trace.find_caller_location_for_deprecated, %(Using `result.wtf?` is deprecated. Please use `#{@stack.to_a[0].task}.wtf?` and have a nice day.)
56
+
43
57
  Developer::Trace::Present.(@stack)
44
58
  end
45
59
 
46
- # TODO: deprecate!
60
+ # TODO: remove in 0.11.0.
47
61
  def wtf?
48
62
  puts wtf
49
63
  end
@@ -1,7 +1,7 @@
1
1
  module Trailblazer
2
2
  module Version
3
3
  module Operation
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.1"
5
5
  end
6
6
  end
7
7
  end
@@ -2,6 +2,9 @@ require "trailblazer/activity/dsl/linear"
2
2
  require 'forwardable'
3
3
  require 'trailblazer/operation/version'
4
4
 
5
+ #
6
+ # Developer's docs: https://trailblazer.to/2.1/docs/internals.html#internals-operation
7
+ #
5
8
  module Trailblazer
6
9
  # As opposed to {Activity::Railway} and {Activity::FastTrack} an operation
7
10
  # maintains different terminus subclasses.
@@ -57,5 +60,3 @@ require "trailblazer/operation/deprecated_macro" # TODO: remove in 2.2.
57
60
 
58
61
  require "trailblazer/operation/result"
59
62
  require "trailblazer/operation/railway"
60
-
61
- require "trailblazer/operation/railway/macaroni"
data/test/step_test.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "test_helper"
2
2
 
3
+ # TODO: throw away this test, most of it is tested in {dsl}.
4
+
3
5
  # Tests
4
6
  # --- step ->(*) { snippet }
5
7
  # --- step Callable
@@ -40,10 +42,18 @@ class StepTest < Minitest::Spec
40
42
 
41
43
  it { Create.(a: 1, b: 2, c: 3, d: 4, e: 5).inspect("a", "b", "c", "d", "e").must_equal "<Result:true [1, 2, 3, 4, 5] >" }
42
44
 
43
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
44
- it { Trailblazer::Developer.railway(Create).gsub(/0x.+?step_test.rb/, "").gsub(/\)\s.+?step_test.rb/, ") test/step_test.rb").must_equal %{[>#<Proc::30 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c(options, c: ..., **) test/step_test.rb:18>,>d,>MyMacro]} }
45
- else
46
- it { Trailblazer::Developer.railway(Create).gsub(/0x.+?step_test.rb/, "").must_equal %{[>#<Proc::30 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c>,>d,>MyMacro]} }
45
+ it "allows {Developer.railway}" do
46
+ output = Trailblazer::Developer.railway(Create)
47
+ .gsub(/0x.+?step_test.rb/, "")
48
+ .gsub(/\)\s.+?step_test.rb/, ") test/step_test.rb")
49
+
50
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.2.0")
51
+ assert_equal output, %([>#<Proc::32 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c(options, c: ...) test/step_test.rb:20>,>d,>MyMacro])
52
+ elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
53
+ assert_equal output, %([>#<Proc::32 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c(options, c: ..., **) test/step_test.rb:20>,>d,>MyMacro])
54
+ else
55
+ assert_equal output, %([>#<Proc::32 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c>,>d,>MyMacro])
56
+ end
47
57
  end
48
58
 
49
59
  #---
@@ -173,27 +183,6 @@ class StepTest < Minitest::Spec
173
183
  # FIXME: we have all fast track ends here.
174
184
  it { skip; Ii["__activity__"].circuit.instance_variable_get(:@map).size.must_equal 6 }
175
185
 
176
- #---
177
- #-
178
- # not existent :name
179
- it do
180
- op = assert_raises Trailblazer::Activity::Adds::IndexError do
181
- class InvalidStep < Trailblazer::Operation
182
- step :a, before: "I don't exist!"
183
- end
184
- end
185
-
186
- error_message = %{#<Trailblazer::Activity::Adds::IndexError: StepTest::InvalidStep:
187
- \e[31m\"I don't exist!\" is not a valid step ID. Did you mean any of these ?\e[0m
188
- \e[32m\"Start.default\"
189
- \"End.success\"
190
- \"End.pass_fast\"
191
- \"End.fail_fast\"
192
- \"End.failure\"\e[0m>}
193
-
194
- assert_match error_message, op.inspect
195
- end
196
-
197
186
  #---
198
187
  #- :name
199
188
  #- step :whatever, id: :validate
data/test/trace_test.rb CHANGED
@@ -8,11 +8,35 @@ class TraceTest < Minitest::Spec
8
8
 
9
9
  class Create < Trailblazer::Operation
10
10
  step ->(options, a_return:, **) { options[:a] = a_return }, id: "Create.task.a"
11
- step({task: B, id: "MyNested"}, B.to_h[:outputs][0] => Track(:success))
11
+ step Subprocess(B), id: "MyNested"
12
12
  step ->(options, **) { options[:c] = true }, id: "Create.task.c"
13
13
  step ->(_options, params:, **) { params.any? }, id: "Create.task.params"
14
14
  end
15
- # raise Create["__task_wraps__"].inspect
15
+
16
+ it "deprecates {result.wtf?} and {Operation.trace}" do
17
+ output, warning = capture_io do
18
+ result = Create.trace({a_return: true, params: {}})
19
+ result.wtf?
20
+ end
21
+ line_no = __LINE__ - 2
22
+
23
+ assert_equal warning, %([Trailblazer] #{File.realpath(__FILE__)}:#{line_no - 1} Using `Operation.trace` is deprecated and will be removed in {trailblazer-operation-0.11.0}.
24
+ Please use `TraceTest::Create.wtf?` as documented here: https://trailblazer.to/2.1/docs/trailblazer#trailblazer-developer-wtf-
25
+ [Trailblazer] #{File.realpath(__FILE__)}:#{line_no} Using `result.wtf?` is deprecated. Please use `TraceTest::Create.wtf?` and have a nice day.
26
+ )
27
+ assert_equal output, %(TraceTest::Create
28
+ |-- Start.default
29
+ |-- Create.task.a
30
+ |-- MyNested
31
+ | |-- Start.default
32
+ | |-- B.task.b
33
+ | |-- B.task.e
34
+ | `-- End.success
35
+ |-- Create.task.c
36
+ |-- Create.task.params
37
+ `-- End.failure
38
+ )
39
+ end
16
40
 
17
41
  it "allows using low-level Operation::Trace" do
18
42
  result = Trailblazer::Operation::Trace.(
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["apotonick@gmail.com"]
10
10
  spec.description = %q(Trailblazer's operation object.)
11
11
  spec.summary = %q(Trailblazer's operation object with railway flow and integrated error handling.)
12
- spec.homepage = "http://trailblazer.to"
12
+ spec.homepage = "https://trailblazer.to/2.1/docs/operation.html"
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "trailblazer-activity-dsl-linear", ">= 1.1.0", "< 1.2.0"
21
- spec.add_dependency "trailblazer-developer", ">= 0.0.26"
20
+ spec.add_dependency "trailblazer-activity-dsl-linear", ">= 1.2.0", "< 1.4.0"
21
+ spec.add_dependency "trailblazer-developer", ">= 0.1.0", "< 0.2.0"
22
22
 
23
23
  spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency "minitest-line"
25
26
  spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rubocop"
27
27
 
28
- spec.required_ruby_version = ">= 2.1.0"
28
+ spec.required_ruby_version = ">= 2.5.0"
29
29
  end
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.9.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-14 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-activity-dsl-linear
@@ -16,34 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: 1.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.2.0
22
+ version: 1.4.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 1.1.0
29
+ version: 1.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.2.0
32
+ version: 1.4.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: trailblazer-developer
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.0.26
39
+ version: 0.1.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 0.2.0
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
47
  - - ">="
45
48
  - !ruby/object:Gem::Version
46
- version: 0.0.26
49
+ version: 0.1.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 0.2.0
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: bundler
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +79,7 @@ dependencies:
73
79
  - !ruby/object:Gem::Version
74
80
  version: '0'
75
81
  - !ruby/object:Gem::Dependency
76
- name: rake
82
+ name: minitest-line
77
83
  requirement: !ruby/object:Gem::Requirement
78
84
  requirements:
79
85
  - - ">="
@@ -87,7 +93,7 @@ dependencies:
87
93
  - !ruby/object:Gem::Version
88
94
  version: '0'
89
95
  - !ruby/object:Gem::Dependency
90
- name: rubocop
96
+ name: rake
91
97
  requirement: !ruby/object:Gem::Requirement
92
98
  requirements:
93
99
  - - ">="
@@ -108,21 +114,16 @@ extensions: []
108
114
  extra_rdoc_files: []
109
115
  files:
110
116
  - ".github/workflows/ci.yml"
111
- - ".github/workflows/ci_jruby.yml"
112
- - ".github/workflows/ci_legacy.yml"
113
- - ".github/workflows/ci_truffleruby.yml"
114
117
  - ".gitignore"
115
118
  - CHANGES.md
116
119
  - Gemfile
117
120
  - README.md
118
121
  - Rakefile
119
122
  - lib/trailblazer/operation.rb
120
- - lib/trailblazer/operation/callable.rb
121
123
  - lib/trailblazer/operation/class_dependencies.rb
122
124
  - lib/trailblazer/operation/deprecated_macro.rb
123
125
  - lib/trailblazer/operation/public_call.rb
124
126
  - lib/trailblazer/operation/railway.rb
125
- - lib/trailblazer/operation/railway/macaroni.rb
126
127
  - lib/trailblazer/operation/result.rb
127
128
  - lib/trailblazer/operation/trace.rb
128
129
  - lib/trailblazer/operation/version.rb
@@ -152,7 +153,7 @@ files:
152
153
  - test/wiring/defaults_test.rb
153
154
  - test/wiring/subprocess_test.rb
154
155
  - trailblazer-operation.gemspec
155
- homepage: http://trailblazer.to
156
+ homepage: https://trailblazer.to/2.1/docs/operation.html
156
157
  licenses:
157
158
  - MIT
158
159
  metadata: {}
@@ -164,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
165
  requirements:
165
166
  - - ">="
166
167
  - !ruby/object:Gem::Version
167
- version: 2.1.0
168
+ version: 2.5.0
168
169
  required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  requirements:
170
171
  - - ">="
@@ -1,19 +0,0 @@
1
- ## This file is managed by Terraform.
2
- ## Do not modify this file directly, as it may be overwritten.
3
- ## Please open an issue instead.
4
- name: CI JRuby
5
- on: [push, pull_request]
6
- jobs:
7
- test:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: [jruby, jruby-head]
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: ${{ matrix.ruby }}
18
- bundler-cache: true
19
- - run: bundle exec rake
@@ -1,19 +0,0 @@
1
- ## This file is managed by Terraform.
2
- ## Do not modify this file directly, as it may be overwritten.
3
- ## Please open an issue instead.
4
- name: CI with EOL ruby versions
5
- on: [push, pull_request]
6
- jobs:
7
- test:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: [2.5, 2.6]
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: ${{ matrix.ruby }}
18
- bundler-cache: true
19
- - run: bundle exec rake
@@ -1,19 +0,0 @@
1
- ## This file is managed by Terraform.
2
- ## Do not modify this file directly, as it may be overwritten.
3
- ## Please open an issue instead.
4
- name: CI TruffleRuby
5
- on: [push, pull_request]
6
- jobs:
7
- test:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: [truffleruby, truffleruby-head]
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: ${{ matrix.ruby }}
18
- bundler-cache: true
19
- - run: bundle exec rake
@@ -1,42 +0,0 @@
1
- module Trailblazer
2
- class Operation
3
- # Use {Callable} if you have an operation or any other callable object that does
4
- # _not_ expose an {Activity interface}. For example, {Operation.call} isn't compatible
5
- # with activities, hence you need to decorate it using {Callable}. The returned object
6
- # exposes an {Activity interface}.
7
- #
8
- # @param :call [Symbol] Method name to call
9
- # @param options [Hash] Hash to merge into {circuit_options}, e.g. {:start_task}.
10
- #
11
- # @example Create and use a Callable instance.
12
- # callable = Trailblazer::Operation::Callable( Memo::Create, call: :__call__ )
13
- # callable.( [ctx, {}] ) #=> Activity interface, ::call will invoke Memo::Create.__call__.
14
- def self.Callable(*args)
15
- Callable.new(*args)
16
- end
17
-
18
- # Subprocess allows to have tasks with a different call interface and start event.
19
- # @param activity any object with an {Activity interface}
20
- class Callable
21
- include Activity::Interface
22
-
23
- def initialize(activity, call: :call, **options)
24
- @activity = activity
25
- @options = options
26
- @call = call
27
- end
28
-
29
- def call(args, **circuit_options)
30
- @activity.public_send(@call, args, circuit_options.merge(@options))
31
- end
32
-
33
- extend Forwardable
34
- # @private
35
- def_delegators :@activity, :to_h, :debug
36
-
37
- def to_s
38
- %{#<Trailblazer::Activity::Callable activity=#{@activity}>}
39
- end
40
- end
41
- end
42
- end
@@ -1,23 +0,0 @@
1
- module Trailblazer
2
- module Operation::Railway
3
- # Call the user's steps with a differing API (inspired by Maciej Mensfeld) that
4
- # only receives keyword args. The `options` keyword is the stateful context object
5
- #
6
- # def my_step( params:, ** )
7
- # def my_step( params:, options:, ** )
8
- module Macaroni
9
- def self.call(user_proc)
10
- Activity::TaskBuilder::Task.new(Trailblazer::Option.build(Macaroni::Option, user_proc), user_proc)
11
- end
12
-
13
- class Option < Trailblazer::Option
14
- # The Option#call! method prepares the arguments.
15
- def self.call!(proc, options, *)
16
- proc.(**options.to_hash.merge(options: options))
17
- end
18
- end
19
- end
20
-
21
- KwSignature = Macaroni
22
- end
23
- end