convenient_service 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/lib/convenient_service/configs/minimal.rb +12 -2
  4. data/lib/convenient_service/configs/standard.rb +0 -4
  5. data/lib/convenient_service/examples/standard/gemfile/services/assert_npm_package_available.rb +10 -0
  6. data/lib/convenient_service/examples/standard/gemfile/services/format.rb +10 -0
  7. data/lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb +10 -0
  8. data/lib/convenient_service/examples/standard/gemfile/services/parse_content.rb +10 -0
  9. data/lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb +10 -0
  10. data/lib/convenient_service/examples/standard/gemfile/services/replace_file_content.rb +10 -0
  11. data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_body.rb +10 -0
  12. data/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path.rb +10 -0
  13. data/lib/convenient_service/examples/standard/request_params/services/validate_casted_params.rb +10 -0
  14. data/lib/convenient_service/examples/standard/request_params/services/validate_uncasted_params.rb +10 -0
  15. data/lib/convenient_service/factories/services.rb +40 -0
  16. data/lib/convenient_service/factories/step/instance.rb +11 -1
  17. data/lib/convenient_service/rspec/matchers/custom/delegate_to/entities/matcher.rb +2 -2
  18. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_method_step.rb +4 -4
  19. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_result_method_step.rb +4 -4
  20. data/lib/convenient_service/rspec/matchers/custom/results/base/commands/find_result_service_step.rb +1 -1
  21. data/lib/convenient_service/service/plugins/aliases.rb +1 -1
  22. data/lib/convenient_service/service/plugins/{has_result_method_steps → can_have_method_steps}/middleware.rb +12 -2
  23. data/lib/convenient_service/service/plugins/can_have_method_steps.rb +3 -0
  24. data/lib/convenient_service/service/plugins/can_have_result_step/middleware.rb +43 -0
  25. data/lib/convenient_service/service/plugins/can_have_result_step.rb +3 -0
  26. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/commands/create_step_class.rb +1 -1
  27. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/concern.rb +8 -8
  28. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands/cast_method.rb +1 -1
  29. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands/cast_method_caller.rb +1 -1
  30. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands/cast_method_direction.rb +1 -1
  31. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands/cast_method_key.rb +1 -1
  32. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands/cast_method_name.rb +1 -1
  33. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands/define_method_in_container.rb +3 -3
  34. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/concern/class_methods.rb +1 -1
  35. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/concern/instance_methods.rb +1 -1
  36. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/concern.rb +1 -1
  37. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/alias.rb +1 -1
  38. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/base.rb +1 -1
  39. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/proc.rb +1 -1
  40. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/raw.rb +1 -1
  41. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/reassignment/commands/define_method_in_container.rb +1 -1
  42. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/reassignment.rb +1 -1
  43. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/usual.rb +1 -1
  44. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/directions/base.rb +1 -1
  45. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/directions/input.rb +1 -1
  46. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/directions/output.rb +1 -1
  47. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/key.rb +1 -1
  48. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/name.rb +1 -1
  49. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/values/reassignment.rb +1 -1
  50. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/errors.rb +1 -1
  51. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method.rb +1 -1
  52. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/service/class_methods.rb +1 -1
  53. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/service.rb +1 -1
  54. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/commands/cast_params.rb +1 -1
  55. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/commands/extract_params.rb +1 -1
  56. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/concern/instance_methods.rb +1 -1
  57. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/concern.rb +1 -1
  58. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/errors.rb +1 -1
  59. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins/can_have_parent_result/middleware.rb +1 -1
  60. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins/has_inspect/concern.rb +1 -1
  61. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/structs/params.rb +1 -1
  62. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step.rb +1 -1
  63. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step_collection.rb +2 -2
  64. data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/middleware.rb +4 -4
  65. data/lib/convenient_service/service/plugins/can_have_steps.rb +6 -0
  66. data/lib/convenient_service/service/plugins/can_have_stubbed_result/concern.rb +18 -1
  67. data/lib/convenient_service/service/plugins.rb +3 -2
  68. data/lib/convenient_service/version.rb +1 -1
  69. metadata +59 -57
  70. data/lib/convenient_service/service/plugins/has_result_method_steps.rb +0 -3
  71. data/lib/convenient_service/service/plugins/has_result_steps.rb +0 -6
  72. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/commands.rb +0 -0
  73. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/commands.rb +0 -0
  74. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers/reassignment/commands.rb +0 -0
  75. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/callers.rb +0 -0
  76. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/directions.rb +0 -0
  77. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities/values.rb +0 -0
  78. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/method/entities.rb +0 -0
  79. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/commands.rb +0 -0
  80. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins/can_have_parent_result.rb +0 -0
  81. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins/has_inspect.rb +0 -0
  82. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/plugins.rb +0 -0
  83. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities/step/structs.rb +0 -0
  84. /data/lib/convenient_service/service/plugins/{has_result_steps → can_have_steps}/entities.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ae92003a48bd04299fc7d8d6036c3d1c94e1a0e2a436c645969350bc3653a6a
4
- data.tar.gz: 177c46a70660b06e1985c4653cfc2ade49c07e9353880847c19b41e5017d3a05
3
+ metadata.gz: a1f3cda1e00bba0f7e8c4e86e8831d6bb55385302c2da872cc6a205970938558
4
+ data.tar.gz: be1745b3ef9fbc5e7c892d2b15b65eda18afa2879a8c5253d67effe3c9f0c506
5
5
  SHA512:
6
- metadata.gz: 80e69d94ebbd681b3d9aaabd78367b3a104e3e452b596c5cfbf3b32ee6a2855b1352712ee0645c095eed9e66fdd6337be27ff2b9eb14bebf61166314db3d7d40
7
- data.tar.gz: 28bea96a05480a11360d261b853039fbc7fd364a2a495280cc457e083d62271b66ed861f089a9ad0172910976cfa1326c53a599fb2bf91ebbca68bba5e688e14
6
+ metadata.gz: 9fe6b8fe017c94dec0516b342d1d1bce0ee968487b94cb0695414a5f5781c4cd95e1b42ec2e31f746df430caec82e2c2d39c6423d638bf838d17ab72ba8816c6
7
+ data.tar.gz: 4972e2fe5f288b989d42260eb86f4750614a9a16bc2b08a98eae2f6b94c8fb32f10d05daf33f37c9213ec1e134f4962a7c4d9dfba380351c801811acc7eabb01
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.0](https://github.com/marian13/convenient_service/compare/v0.10.1...v0.11.0) (2023-03-04)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **can_have_method_steps:** rename has_result_method_steps to can_have_method_steps
9
+ * **can_have_steps:** rename has_result_steps to can_have_steps
10
+
11
+ ### Bug Fixes
12
+
13
+ * **can_have_method_steps:** disable CanHaveMethodSteps in Standard config ([af0b039](https://github.com/marian13/convenient_service/commit/af0b039c827769441bb5adc150d0e0ff2a43e220))
14
+
15
+
16
+ ### Code Refactoring
17
+
18
+ * **can_have_method_steps:** rename has_result_method_steps to can_have_method_steps ([39901a3](https://github.com/marian13/convenient_service/commit/39901a31e37536ae81c6961b45a8c35e505aaefa))
19
+ * **can_have_steps:** rename has_result_steps to can_have_steps ([691d8e1](https://github.com/marian13/convenient_service/commit/691d8e128fc4ff8d1dfa76e365501b0d2028a5aa))
20
+
21
+
22
+ ### Miscellaneous Chores
23
+
24
+ * release 0.11.0 ([dc6282a](https://github.com/marian13/convenient_service/commit/dc6282a7a09e5194c395b2399bd418a0e4d15de9))
25
+
26
+ ## [0.10.1](https://github.com/marian13/convenient_service/compare/v0.10.0...v0.10.1) (2023-03-02)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * **can_have_stubbed_result:** add thread-safety ([1962dcc](https://github.com/marian13/convenient_service/commit/1962dccdea29fb36c1b581e312329f41bb23c179))
32
+
3
33
  ## [0.10.0](https://github.com/marian13/convenient_service/compare/v0.9.0...v0.10.0) (2023-03-01)
4
34
 
5
35
 
@@ -34,7 +34,7 @@ module ConvenientService
34
34
  use Plugins::Common::HasConstructorWithoutInitialize::Concern
35
35
 
36
36
  use Plugins::Service::HasResult::Concern
37
- use Plugins::Service::HasResultSteps::Concern
37
+ use Plugins::Service::CanHaveSteps::Concern
38
38
  end
39
39
 
40
40
  middlewares :initialize do
@@ -45,7 +45,7 @@ module ConvenientService
45
45
  use Plugins::Common::NormalizesEnv::Middleware
46
46
 
47
47
  use Plugins::Service::HasResult::Middleware
48
- use Plugins::Service::HasResultSteps::Middleware
48
+ use Plugins::Service::CanHaveSteps::Middleware
49
49
  end
50
50
 
51
51
  middlewares :step do
@@ -70,6 +70,16 @@ module ConvenientService
70
70
 
71
71
  middlewares :step, scope: :class do
72
72
  use Plugins::Common::NormalizesEnv::Middleware
73
+
74
+ ##
75
+ # IMPORTANT:
76
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
77
+ # - It will be reenabled after the introduction of thread-safety specs.
78
+ # - Do not use it in production yet.
79
+ #
80
+ # use Plugins::Service::CanHaveMethodSteps::Middleware
81
+
82
+ use Plugins::Service::CanHaveResultStep::Middleware
73
83
  end
74
84
 
75
85
  class self::Internals
@@ -66,10 +66,6 @@ module ConvenientService
66
66
  use Plugins::Service::HasResultShortSyntax::Error::Middleware
67
67
  end
68
68
 
69
- middlewares :step, scope: :class do
70
- use Plugins::Service::HasResultMethodSteps::Middleware
71
- end
72
-
73
69
  class self::Result
74
70
  concerns do
75
71
  use Plugins::Result::HasResultShortSyntax::Concern
@@ -13,6 +13,16 @@ module ConvenientService
13
13
  class AssertNpmPackageAvailable
14
14
  include ConvenientService::Standard::Config
15
15
 
16
+ ##
17
+ # IMPORTANT:
18
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
19
+ # - It will be reenabled after the introduction of thread-safety specs.
20
+ # - Do not use it in production yet.
21
+ #
22
+ middlewares :step, scope: :class do
23
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
24
+ end
25
+
16
26
  attr_reader :name
17
27
 
18
28
  step :validate_name
@@ -14,6 +14,16 @@ module ConvenientService
14
14
  class Format
15
15
  include ConvenientService::Standard::Config
16
16
 
17
+ ##
18
+ # IMPORTANT:
19
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
20
+ # - It will be reenabled after the introduction of thread-safety specs.
21
+ # - Do not use it in production yet.
22
+ #
23
+ middlewares :step, scope: :class do
24
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
25
+ end
26
+
17
27
  attr_reader :path
18
28
 
19
29
  step :validate_path,
@@ -8,6 +8,16 @@ module ConvenientService
8
8
  class MergeSections
9
9
  include ConvenientService::Standard::Config
10
10
 
11
+ ##
12
+ # IMPORTANT:
13
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
14
+ # - It will be reenabled after the introduction of thread-safety specs.
15
+ # - Do not use it in production yet.
16
+ #
17
+ middlewares :step, scope: :class do
18
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
19
+ end
20
+
11
21
  attr_reader :header, :body
12
22
 
13
23
  step :validate_header,
@@ -40,6 +40,16 @@ module ConvenientService
40
40
 
41
41
  include ConvenientService::Standard::Config
42
42
 
43
+ ##
44
+ # IMPORTANT:
45
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
46
+ # - It will be reenabled after the introduction of thread-safety specs.
47
+ # - Do not use it in production yet.
48
+ #
49
+ middlewares :step, scope: :class do
50
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
51
+ end
52
+
43
53
  attr_reader :content
44
54
 
45
55
  step :validate_content
@@ -8,6 +8,16 @@ module ConvenientService
8
8
  class ReadFileContent
9
9
  include ConvenientService::Standard::Config
10
10
 
11
+ ##
12
+ # IMPORTANT:
13
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
14
+ # - It will be reenabled after the introduction of thread-safety specs.
15
+ # - Do not use it in production yet.
16
+ #
17
+ middlewares :step, scope: :class do
18
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
19
+ end
20
+
11
21
  attr_reader :path
12
22
 
13
23
  step :validate_path
@@ -8,6 +8,16 @@ module ConvenientService
8
8
  class ReplaceFileContent
9
9
  include ConvenientService::Standard::Config
10
10
 
11
+ ##
12
+ # IMPORTANT:
13
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
14
+ # - It will be reenabled after the introduction of thread-safety specs.
15
+ # - Do not use it in production yet.
16
+ #
17
+ middlewares :step, scope: :class do
18
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
19
+ end
20
+
11
21
  attr_reader :path, :content
12
22
 
13
23
  step :validate_path, in: :path
@@ -8,6 +8,16 @@ module ConvenientService
8
8
  class ExtractParamsFromBody
9
9
  include ConvenientService::Standard::Config
10
10
 
11
+ ##
12
+ # IMPORTANT:
13
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
14
+ # - It will be reenabled after the introduction of thread-safety specs.
15
+ # - Do not use it in production yet.
16
+ #
17
+ middlewares :step, scope: :class do
18
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
19
+ end
20
+
11
21
  attr_reader :request
12
22
 
13
23
  step :parse_body, in: :request, out: :body
@@ -8,6 +8,16 @@ module ConvenientService
8
8
  class ExtractParamsFromPath
9
9
  include ConvenientService::Standard::Config
10
10
 
11
+ ##
12
+ # IMPORTANT:
13
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
14
+ # - It will be reenabled after the introduction of thread-safety specs.
15
+ # - Do not use it in production yet.
16
+ #
17
+ middlewares :step, scope: :class do
18
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
19
+ end
20
+
11
21
  attr_reader :request, :pattern
12
22
 
13
23
  step :parse_path, in: :request, out: :path
@@ -8,6 +8,16 @@ module ConvenientService
8
8
  class ValidateCastedParams
9
9
  include ConvenientService::Standard::Config
10
10
 
11
+ ##
12
+ # IMPORTANT:
13
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
14
+ # - It will be reenabled after the introduction of thread-safety specs.
15
+ # - Do not use it in production yet.
16
+ #
17
+ middlewares :step, scope: :class do
18
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
19
+ end
20
+
11
21
  attr_reader \
12
22
  :original_id,
13
23
  :original_format,
@@ -8,6 +8,16 @@ module ConvenientService
8
8
  class ValidateUncastedParams
9
9
  include ConvenientService::Standard::Config
10
10
 
11
+ ##
12
+ # IMPORTANT:
13
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
14
+ # - It will be reenabled after the introduction of thread-safety specs.
15
+ # - Do not use it in production yet.
16
+ #
17
+ middlewares :step, scope: :class do
18
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
19
+ end
20
+
11
21
  attr_reader :id, :format, :title, :description, :tags, :sources
12
22
 
13
23
  step :validate_id, in: :id
@@ -22,6 +22,16 @@ module ConvenientService
22
22
  ::Class.new do
23
23
  include ::ConvenientService::Configs::Standard
24
24
 
25
+ ##
26
+ # IMPORTANT:
27
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
28
+ # - It will be reenabled after the introduction of thread-safety specs.
29
+ # - Do not use it in production yet.
30
+ #
31
+ middlewares :step, scope: :class do
32
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
33
+ end
34
+
25
35
  def result
26
36
  success
27
37
  end
@@ -60,6 +70,16 @@ module ConvenientService
60
70
  ::Class.new do
61
71
  include ::ConvenientService::Configs::Standard
62
72
 
73
+ ##
74
+ # IMPORTANT:
75
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
76
+ # - It will be reenabled after the introduction of thread-safety specs.
77
+ # - Do not use it in production yet.
78
+ #
79
+ middlewares :step, scope: :class do
80
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
81
+ end
82
+
63
83
  def result
64
84
  failure(data)
65
85
  end
@@ -88,6 +108,16 @@ module ConvenientService
88
108
  ::Class.new do
89
109
  include ::ConvenientService::Configs::Standard
90
110
 
111
+ ##
112
+ # IMPORTANT:
113
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
114
+ # - It will be reenabled after the introduction of thread-safety specs.
115
+ # - Do not use it in production yet.
116
+ #
117
+ middlewares :step, scope: :class do
118
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
119
+ end
120
+
91
121
  def result
92
122
  error(message)
93
123
  end
@@ -165,6 +195,16 @@ module ConvenientService
165
195
  klass.class_exec(steps: steps) do
166
196
  include ::ConvenientService::Configs::Standard
167
197
 
198
+ ##
199
+ # IMPORTANT:
200
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
201
+ # - It will be reenabled after the introduction of thread-safety specs.
202
+ # - Do not use it in production yet.
203
+ #
204
+ middlewares :step, scope: :class do
205
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
206
+ end
207
+
168
208
  steps.each do |step_name|
169
209
  case step_name
170
210
  when ::Class
@@ -8,13 +8,23 @@ module ConvenientService
8
8
  module Step
9
9
  module Instance
10
10
  ##
11
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::Step]
11
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
12
12
  #
13
13
  def create_step_instance
14
14
  service_class =
15
15
  ::Class.new do
16
16
  include ::ConvenientService::Configs::Standard
17
17
 
18
+ ##
19
+ # IMPORTANT:
20
+ # - `CanHaveMethodSteps` is disabled in the Standard config since it causes race conditions in combination with `CanHaveStubbedResult`.
21
+ # - It will be reenabled after the introduction of thread-safety specs.
22
+ # - Do not use it in production yet.
23
+ #
24
+ middlewares :step, scope: :class do
25
+ use ConvenientService::Plugins::Service::CanHaveMethodSteps::Middleware
26
+ end
27
+
18
28
  step :result
19
29
 
20
30
  def result
@@ -16,7 +16,7 @@ module ConvenientService
16
16
  # @internal
17
17
  # specify {
18
18
  # expect { method_class.cast(other, **options) }
19
- # .to delegate_to(ConvenientService::Service::Plugins::HasResultSteps::Entities::Method::Commands::CastMethod, :call)
19
+ # .to delegate_to(ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Commands::CastMethod, :call)
20
20
  # .with_arguments(other: other, options: options)
21
21
  # .and_return_its_value
22
22
  # }
@@ -24,7 +24,7 @@ module ConvenientService
24
24
  # { method_class.cast(other, **options) }
25
25
  # # => block_expectation
26
26
  #
27
- # ConvenientService::Service::Plugins::HasResultSteps::Entities::Method::Commands::CastMethod
27
+ # ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Commands::CastMethod
28
28
  # # => object
29
29
  #
30
30
  # :call
@@ -31,7 +31,7 @@ module ConvenientService
31
31
  end
32
32
 
33
33
  ##
34
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
34
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
35
35
  #
36
36
  def call
37
37
  return nil unless result.step
@@ -42,7 +42,7 @@ module ConvenientService
42
42
  private
43
43
 
44
44
  ##
45
- # @param input [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
45
+ # @param input [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
46
46
  # @return [Boolean]
47
47
  #
48
48
  def match_service_class?(input)
@@ -50,7 +50,7 @@ module ConvenientService
50
50
  end
51
51
 
52
52
  ##
53
- # @param input [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
53
+ # @param input [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
54
54
  # @return [Boolean]
55
55
  #
56
56
  def match_key?(input)
@@ -58,7 +58,7 @@ module ConvenientService
58
58
  end
59
59
 
60
60
  ##
61
- # @param input [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
61
+ # @param input [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
62
62
  # @return [Boolean]
63
63
  #
64
64
  def match_value?(input)
@@ -23,7 +23,7 @@ module ConvenientService
23
23
  end
24
24
 
25
25
  ##
26
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
26
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
27
27
  #
28
28
  def call
29
29
  return nil unless result.step
@@ -34,7 +34,7 @@ module ConvenientService
34
34
  private
35
35
 
36
36
  ##
37
- # @param input [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
37
+ # @param input [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
38
38
  # @return [Boolean]
39
39
  #
40
40
  def match_service_class?(input)
@@ -42,7 +42,7 @@ module ConvenientService
42
42
  end
43
43
 
44
44
  ##
45
- # @param input [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
45
+ # @param input [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
46
46
  # @return [Boolean]
47
47
  #
48
48
  def match_key?(input)
@@ -50,7 +50,7 @@ module ConvenientService
50
50
  end
51
51
 
52
52
  ##
53
- # @param input [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
53
+ # @param input [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
54
54
  # @return [Boolean]
55
55
  #
56
56
  def match_value?(input)
@@ -31,7 +31,7 @@ module ConvenientService
31
31
  end
32
32
 
33
33
  ##
34
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method]
34
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method]
35
35
  #
36
36
  def call
37
37
  return nil unless result.step
@@ -4,6 +4,6 @@ module ConvenientService
4
4
  module Plugins
5
5
  Result = ::ConvenientService::Service::Plugins::HasResult::Entities::Result::Plugins
6
6
  Service = ::ConvenientService::Service::Plugins
7
- Step = ::ConvenientService::Service::Plugins::HasResultSteps::Entities::Step::Plugins
7
+ Step = ::ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step::Plugins
8
8
  end
9
9
  end
@@ -3,9 +3,14 @@
3
3
  module ConvenientService
4
4
  module Service
5
5
  module Plugins
6
- module HasResultMethodSteps
6
+ module CanHaveMethodSteps
7
7
  class Middleware < Core::MethodChainMiddleware
8
8
  ##
9
+ # @param args [Array]
10
+ # @param kwargs [Hash]
11
+ # @param block [Proc, nil]
12
+ # @return [ConvenientService::Service::Plugins::HasResult::Entities::Result]
13
+ #
9
14
  # @internal
10
15
  # NOTE: It is okish to assign to next method arguments here,
11
16
  # since splat for `args` and double splat for `kwargs`
@@ -14,16 +19,21 @@ module ConvenientService
14
19
  #
15
20
  def next(*args, **kwargs, &block)
16
21
  return chain.next(*args, **kwargs, &block) unless args.first.instance_of?(::Symbol)
22
+ return chain.next(*args, **kwargs, &block) if args.first == :result
17
23
 
18
24
  kwargs[:in] = Utils::Array.wrap(kwargs[:in]) + [{method_name: raw(args.first)}, {organizer: :itself}]
19
25
 
20
- args[0] = (args.first == :result) ? Services::RunOwnMethodInOrganizer : Services::RunMethodInOrganizer
26
+ args[0] = Services::RunMethodInOrganizer
21
27
 
22
28
  chain.next(*args, **kwargs, &block)
23
29
  end
24
30
 
25
31
  private
26
32
 
33
+ ##
34
+ # @param object [Object] Can be any type.
35
+ # @return [ConvenientService::Support::RawValue]
36
+ #
27
37
  def raw(object)
28
38
  Support::RawValue.wrap(object)
29
39
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "can_have_method_steps/middleware"
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ConvenientService
4
+ module Service
5
+ module Plugins
6
+ module CanHaveResultStep
7
+ class Middleware < Core::MethodChainMiddleware
8
+ ##
9
+ # @param args [Array]
10
+ # @param kwargs [Hash]
11
+ # @param block [Proc, nil]
12
+ # @return [ConvenientService::Service::Plugins::HasResult::Entities::Result]
13
+ #
14
+ # @internal
15
+ # NOTE: It is okish to assign to next method arguments here,
16
+ # since splat for `args` and double splat for `kwargs`
17
+ # always create new arrays and hashes respectively.
18
+ # https://github.com/ruby/spec/blob/c7ed8478a031d0df346d222495f4b4bbb298523b/language/keyword_arguments_spec.rb#L100
19
+ #
20
+ def next(*args, **kwargs, &block)
21
+ return chain.next(*args, **kwargs, &block) if args.first != :result
22
+
23
+ kwargs[:in] = Utils::Array.wrap(kwargs[:in]) + [{method_name: raw(:result)}, {organizer: :itself}]
24
+
25
+ args[0] = Services::RunOwnMethodInOrganizer
26
+
27
+ chain.next(*args, **kwargs, &block)
28
+ end
29
+
30
+ private
31
+
32
+ ##
33
+ # @param object [Object] Can be any type.
34
+ # @return [ConvenientService::Support::RawValue]
35
+ #
36
+ def raw(object)
37
+ Support::RawValue.wrap(object)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "can_have_result_step/middleware"
@@ -3,7 +3,7 @@
3
3
  module ConvenientService
4
4
  module Service
5
5
  module Plugins
6
- module HasResultSteps
6
+ module CanHaveSteps
7
7
  module Commands
8
8
  class CreateStepClass < Support::Command
9
9
  include Support::DependencyContainer::Import
@@ -3,13 +3,13 @@
3
3
  module ConvenientService
4
4
  module Service
5
5
  module Plugins
6
- module HasResultSteps
6
+ module CanHaveSteps
7
7
  module Concern
8
8
  include Support::Concern
9
9
 
10
10
  instance_methods do
11
11
  ##
12
- # @return [Array<ConvenientService::Service::Plugins::HasResultSteps::Entities::Step>]
12
+ # @return [Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>]
13
13
  #
14
14
  def steps
15
15
  internals.cache.fetch(:steps) do
@@ -25,10 +25,10 @@ module ConvenientService
25
25
  # Returns `nil` when index is out of range.
26
26
  #
27
27
  # @param index [Integer]
28
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::Step]
28
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
29
29
  #
30
30
  # @note This method was initially designed as a hook (callback trigger).
31
- # @see ConvenientService::Service::Plugins::HasResultSteps::Middleware#next
31
+ # @see ConvenientService::Service::Plugins::CanHaveSteps::Middleware#next
32
32
  #
33
33
  def step(index)
34
34
  steps[index]
@@ -41,7 +41,7 @@ module ConvenientService
41
41
  #
42
42
  # @param args [Array]
43
43
  # @param kwargs [Hash]
44
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::Step]
44
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
45
45
  #
46
46
  def step(*args, **kwargs)
47
47
  step_class.new(*args, **kwargs.merge(container: self))
@@ -69,21 +69,21 @@ module ConvenientService
69
69
 
70
70
  ##
71
71
  # @param method_name [String, Symbol]
72
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::Method::Entities::Values::Reassignment]
72
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Method::Entities::Values::Reassignment]
73
73
  #
74
74
  def reassign(method_name)
75
75
  Entities::Method::Entities::Values::Reassignment.new(method_name)
76
76
  end
77
77
 
78
78
  ##
79
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::StepCollection]
79
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::StepCollection]
80
80
  #
81
81
  def steps
82
82
  @steps ||= Entities::StepCollection.new
83
83
  end
84
84
 
85
85
  ##
86
- # @return [ConvenientService::Service::Plugins::HasResultSteps::Entities::Step]
86
+ # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step]
87
87
  #
88
88
  def step_class
89
89
  @step_class ||= Commands::CreateStepClass.call(service_class: self)
@@ -3,7 +3,7 @@
3
3
  module ConvenientService
4
4
  module Service
5
5
  module Plugins
6
- module HasResultSteps
6
+ module CanHaveSteps
7
7
  module Entities
8
8
  class Method
9
9
  module Commands