convenient_service 0.22.0 → 0.24.0

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/convenient_service/dependencies/queries/version.rb +18 -0
  3. data/lib/convenient_service/service/configs/standard.rb +7 -3
  4. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_backtrace.rb +1 -1
  5. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_cause.rb +1 -1
  6. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_class.rb +1 -1
  7. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_exception.rb +2 -2
  8. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_line.rb +1 -1
  9. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands/format_message.rb +1 -1
  10. data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/constants.rb +1 -1
  11. data/lib/convenient_service/service/plugins/can_have_formatted_exceptions.rb +35 -0
  12. data/lib/convenient_service/service/plugins/can_have_handled_exceptions/concern.rb +34 -0
  13. data/lib/convenient_service/service/plugins/{has_j_send_result/entities/result/plugins/can_have_modified_data.rb → can_have_handled_exceptions.rb} +1 -2
  14. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/commands/cast_step_aware_enumerable.rb → can_have_service_aware_enumerables/commands/cast_service_aware_enumerable.rb} +19 -19
  15. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/commands/cast_step_aware_enumerator.rb → can_have_service_aware_enumerables/commands/cast_service_aware_enumerator.rb} +15 -15
  16. data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables/commands.rb +9 -0
  17. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables → can_have_service_aware_enumerables}/concern.rb +18 -9
  18. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/arithmetic_sequence_enumerator.rb +6 -6
  19. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/array.rb +3 -3
  20. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/base.rb +100 -112
  21. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/boolean.rb +3 -3
  22. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/chain_enumerator.rb +21 -21
  23. data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables/entities/service_aware_enumerables/enumerable.rb +1761 -0
  24. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/enumerator.rb +49 -27
  25. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/hash.rb +3 -3
  26. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/lazy_enumerator/jruby.rb +40 -40
  27. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/lazy_enumerator.rb +133 -133
  28. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/object.rb +4 -4
  29. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/object_or_nil.rb +3 -3
  30. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/entities/step_aware_enumerables → can_have_service_aware_enumerables/entities/service_aware_enumerables}/set.rb +3 -3
  31. data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables/entities/service_aware_enumerables.rb +21 -0
  32. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables/commands.rb → can_have_service_aware_enumerables/entities.rb} +1 -2
  33. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables → can_have_service_aware_enumerables}/exceptions.rb +2 -2
  34. data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables.rb +12 -0
  35. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_used_in_service_aware_enumerables/concern.rb +52 -0
  36. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_used_in_service_aware_enumerables.rb +8 -0
  37. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result/middleware.rb +2 -1
  38. data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +1 -0
  39. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_exception/concern.rb +4 -4
  40. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/concern.rb +61 -0
  41. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception.rb +8 -0
  42. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception/concern.rb +46 -0
  43. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception.rb +8 -0
  44. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/concern.rb +97 -0
  45. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes/base.rb +153 -0
  46. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes/many.rb +141 -0
  47. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes/none.rb +106 -0
  48. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes/one.rb +146 -0
  49. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/entities/key_modes.rb +54 -0
  50. data/lib/convenient_service/service/plugins/{can_have_step_aware_enumerables → has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables}/entities.rb +1 -1
  51. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/{can_have_modified_data → can_be_used_in_service_aware_enumerables}/exceptions.rb +1 -1
  52. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables.rb +10 -0
  53. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb +28 -10
  54. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/exceptions.rb +1 -1
  55. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins.rb +3 -1
  56. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb +3 -3
  57. data/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions.rb +0 -2
  58. data/lib/convenient_service/service/plugins.rb +3 -1
  59. data/lib/convenient_service/version.rb +1 -1
  60. metadata +48 -34
  61. data/lib/convenient_service/service/plugins/can_have_step_aware_collections.rb +0 -12
  62. data/lib/convenient_service/service/plugins/can_have_step_aware_enumerables/entities/step_aware_enumerables/enumerable.rb +0 -1113
  63. data/lib/convenient_service/service/plugins/can_have_step_aware_enumerables/entities/step_aware_enumerables.rb +0 -21
  64. data/lib/convenient_service/service/plugins/can_have_step_aware_enumerables.rb +0 -12
  65. data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_modified_data/concern.rb +0 -109
  66. /data/lib/convenient_service/service/plugins/{rescues_result_unhandled_exceptions → can_have_formatted_exceptions}/commands.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c8f0f45805d314b21afa5fdafc59cb20a5bdfb3d1bd2805b4cdab85953229c9
4
- data.tar.gz: b92a6f6ea00c8ea45d328d667d6612dfe4f9d884ee227fbb66eb83907518a06b
3
+ metadata.gz: b223651455eef03afc210c38e6ce570703b35bafc8543633072a019cfbb312fa
4
+ data.tar.gz: ace1e707494c39cfe83e4eda8b72d64b356db659ab437fe49b530b101cef23b1
5
5
  SHA512:
6
- metadata.gz: 1154d803aeca510b922a468eb816a5d26d8c2ac12d089b744f491969f2b1d6ace8f2b98ba183585aca5a28d2c31b5cab993970fedea6ddffa9fd9ef1a77a1acc
7
- data.tar.gz: 71a5f43b90cf24bad64bdf6de40dc4087f36e505c7781e1c563cdf42b411056b32d94b96ce44496d3b6bfa2f8b290c5b5392a56420881f58ff60e20963372c1a
6
+ metadata.gz: 2e79cfb96f54558b5a2382236777543b7bba3f46e3b360919ca0779359bf16a61b7784d6f5d92c6b925813a2714bb1aec20dc6a943656f85d34ba3f37de1bc23
7
+ data.tar.gz: 79510a4c2dc7370b01c09f82b8f062dcab488eb7113f1f85f2c5bde20af5553c1fec19f9cb69c9e81ee4a5b894a73298c793ed2a5eb125757bcb8065231c70fc
@@ -41,6 +41,24 @@ module ConvenientService
41
41
  false
42
42
  end
43
43
 
44
+ ##
45
+ # @return [ConvenientService::Dependencies::Queries::Version]
46
+ #
47
+ # @example Beta version is considered as lower than major version.
48
+ # ConvenientService::Dependencies::Queries::Version.new("4.0.0.beta1") >= 4
49
+ # # => false
50
+ #
51
+ # @example That is why there is a way to compare only by the first segment of version.
52
+ # ConvenientService::Dependencies::Queries::Version.new("4.0.0.beta1").major_version >= 4
53
+ # # => true
54
+ #
55
+ # @internal
56
+ # TODO: Add direct specs.
57
+ #
58
+ def major_version
59
+ self.class.new(gem_version&.segments&.first.to_s)
60
+ end
61
+
44
62
  ##
45
63
  # @return [Gem::Version, nil]
46
64
  #
@@ -90,7 +90,7 @@ module ConvenientService
90
90
  use ConvenientService::Plugins::Service::HasNegatedJSendResult::Concern if options.enabled?(:essential)
91
91
  use ConvenientService::Plugins::Service::CanHaveSteps::Concern if options.enabled?(:essential)
92
92
  use ConvenientService::Plugins::Service::CanHaveConnectedSteps::Concern if options.enabled?(:essential)
93
- use ConvenientService::Plugins::Service::CanHaveStepAwareEnumerables::Concern if options.enabled?(:essential)
93
+ use ConvenientService::Plugins::Service::CanHaveServiceAwareEnumerables::Concern if options.enabled?(:essential)
94
94
  use ConvenientService::Plugins::Service::CanBeCalled::Concern if options.enabled?(:essential)
95
95
  use ConvenientService::Plugins::Common::CanHaveCallbacks::Concern if options.enabled?(:callbacks)
96
96
  use ConvenientService::Plugins::Service::CanHaveFallbacks::Concern if options.enabled?(:fallbacks)
@@ -100,6 +100,7 @@ module ConvenientService
100
100
  use ConvenientService::Plugins::Common::CachesConstructorArguments::Concern if options.enabled?(:recalculation)
101
101
  use ConvenientService::Plugins::Common::CanBeCopied::Concern if options.enabled?(:recalculation)
102
102
  use ConvenientService::Plugins::Service::CanHaveRecalculations::Concern if options.enabled?(:recalculation)
103
+ use ConvenientService::Plugins::Service::CanHaveHandledExceptions::Concern if options.enabled?(:essential)
103
104
  use ConvenientService::Plugins::Service::CanNotBeInherited::Concern if options.enabled?(:code_review_automation)
104
105
  use ConvenientService::Plugins::Service::HasJSendResultShortSyntax::Concern if options.enabled?(:short_syntax)
105
106
  use ConvenientService::Plugins::Service::HasJSendResultStatusCheckShortSyntax::Concern if options.enabled?(:short_syntax)
@@ -219,12 +220,14 @@ module ConvenientService
219
220
  use ConvenientService::Plugins::Result::CanHaveStep::Concern if options.enabled?(:essential)
220
221
  use ConvenientService::Plugins::Result::CanBeCalled::Concern if options.enabled?(:essential)
221
222
  use ConvenientService::Plugins::Result::CanBeStrict::Concern if options.enabled?(:essential)
222
- use ConvenientService::Plugins::Result::CanHaveModifiedData::Concern if options.enabled?(:essential)
223
+ use ConvenientService::Plugins::Result::CanBeUsedInServiceAwareEnumerables::Concern if options.enabled?(:essential)
223
224
  use ConvenientService::Plugins::Result::HasNegatedResult::Concern if options.enabled?(:essential)
224
225
  use ConvenientService::Plugins::Result::HasPatternMatchingSupport::Concern if options.enabled?(:essential)
225
226
  use ConvenientService::Plugins::Result::CanBeFromFallback::Concern if options.enabled?(:fallbacks)
226
227
  use ConvenientService::Plugins::Result::CanHaveFallbacks::Concern if options.enabled?(:fallbacks)
227
- use ConvenientService::Plugins::Result::CanBeFromException::Concern if options.enabled?(:fault_tolerance)
228
+ use ConvenientService::Plugins::Result::CanBeFromException::Concern if options.enabled?(:essential)
229
+ use ConvenientService::Plugins::Result::CanBeFromHandledException::Concern if options.enabled?(:essential)
230
+ use ConvenientService::Plugins::Result::CanBeFromUnhandledException::Concern if options.enabled?(:fault_tolerance)
228
231
  use ConvenientService::Plugins::Result::HasInspect::Concern if options.enabled?(:inspect)
229
232
  use ConvenientService::Plugins::Result::HasAwesomePrintInspect::Concern if options.enabled?(:awesome_print_inspect)
230
233
  use ConvenientService::Plugins::Result::HasAmazingPrintInspect::Concern if options.enabled?(:amazing_print_inspect)
@@ -338,6 +341,7 @@ module ConvenientService
338
341
  use ConvenientService::Plugins::Step::CanBeCompleted::Concern if options.enabled?(:essential)
339
342
  use ConvenientService::Plugins::Step::CanBeServiceStep::Concern if options.enabled?(:essential)
340
343
  use ConvenientService::Plugins::Step::CanBeMethodStep::Concern if options.enabled?(:essential)
344
+ use ConvenientService::Plugins::Step::CanBeUsedInServiceAwareEnumerables::Concern if options.enabled?(:essential)
341
345
  use ConvenientService::Plugins::Common::CanHaveCallbacks::Concern if options.enabled?(:callbacks)
342
346
  use ConvenientService::Plugins::Step::CanHaveFallbacks::Concern if options.enabled?(:fallbacks)
343
347
  use ConvenientService::Plugins::Step::HasInspect::Concern if options.enabled?(:inspect)
@@ -8,7 +8,7 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module RescuesResultUnhandledExceptions
11
+ module CanHaveFormattedExceptions
12
12
  module Commands
13
13
  class FormatBacktrace < Support::Command
14
14
  ##
@@ -8,7 +8,7 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module RescuesResultUnhandledExceptions
11
+ module CanHaveFormattedExceptions
12
12
  module Commands
13
13
  class FormatCause < Support::Command
14
14
  ##
@@ -8,7 +8,7 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module RescuesResultUnhandledExceptions
11
+ module CanHaveFormattedExceptions
12
12
  module Commands
13
13
  class FormatClass < Support::Command
14
14
  ##
@@ -8,7 +8,7 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module RescuesResultUnhandledExceptions
11
+ module CanHaveFormattedExceptions
12
12
  module Commands
13
13
  class FormatException < Support::Command
14
14
  ##
@@ -49,7 +49,7 @@ module ConvenientService
49
49
  # @param max_backtrace_size [Integer]
50
50
  # @return [void]
51
51
  #
52
- def initialize(exception:, args:, kwargs:, block:, max_backtrace_size: Constants::DEFAULT_MAX_BACKTRACE_SIZE)
52
+ def initialize(exception:, args: [], kwargs: {}, block: nil, max_backtrace_size: Constants::DEFAULT_MAX_BACKTRACE_SIZE)
53
53
  @exception = exception
54
54
  @args = args
55
55
  @kwargs = kwargs
@@ -8,7 +8,7 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module RescuesResultUnhandledExceptions
11
+ module CanHaveFormattedExceptions
12
12
  module Commands
13
13
  class FormatLine < Support::Command
14
14
  ##
@@ -8,7 +8,7 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module RescuesResultUnhandledExceptions
11
+ module CanHaveFormattedExceptions
12
12
  module Commands
13
13
  class FormatMessage < Support::Command
14
14
  ##
@@ -8,7 +8,7 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module RescuesResultUnhandledExceptions
11
+ module CanHaveFormattedExceptions
12
12
  module Constants
13
13
  ##
14
14
  # @return [Integer]
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ # @author Marian Kostyk <mariankostyk13895@gmail.com>
5
+ # @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
6
+ ##
7
+
8
+ require_relative "can_have_formatted_exceptions/commands"
9
+ require_relative "can_have_formatted_exceptions/constants"
10
+
11
+ module ConvenientService
12
+ module Service
13
+ module Plugins
14
+ module CanHaveFormattedExceptions
15
+ class << self
16
+ ##
17
+ # @return [Integer]
18
+ #
19
+ def default_max_backtrace_size
20
+ Constants::DEFAULT_MAX_BACKTRACE_SIZE
21
+ end
22
+
23
+ ##
24
+ # @param exception [StandardError]
25
+ # @param kwargs [Hash{Symbol => Object}]
26
+ # @return [String]
27
+ #
28
+ def format_exception(exception, **kwargs)
29
+ Commands::FormatException.call(exception: exception, **kwargs)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ # @author Marian Kostyk <mariankostyk13895@gmail.com>
5
+ # @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
6
+ ##
7
+
8
+ module ConvenientService
9
+ module Service
10
+ module Plugins
11
+ module CanHaveHandledExceptions
12
+ module Concern
13
+ include Support::Concern
14
+
15
+ instance_methods do
16
+ ##
17
+ # @api public
18
+ # @param max_backtrace_size [Integer]
19
+ # @return [ConvenientService::Service::Plugins::HasJSendResult::Entities::Result]
20
+ #
21
+ def error_from_exception(exception, max_backtrace_size: Plugins::CanHaveFormattedExceptions.default_max_backtrace_size)
22
+ error(
23
+ data: {handled_exception: exception},
24
+ message: Plugins::CanHaveFormattedExceptions.format_exception(exception, max_backtrace_size: max_backtrace_size),
25
+ code: :handled_exception
26
+ )
27
+ .copy(overrides: {kwargs: {exceptions: {handled: exception}}})
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -5,5 +5,4 @@
5
5
  # @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
6
6
  ##
7
7
 
8
- require_relative "can_have_modified_data/concern"
9
- require_relative "can_have_modified_data/exceptions"
8
+ require_relative "can_have_handled_exceptions/concern"
@@ -8,20 +8,20 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module CanHaveStepAwareEnumerables
11
+ module CanHaveServiceAwareEnumerables
12
12
  module Commands
13
- class CastStepAwareEnumerable < Support::Command
13
+ class CastServiceAwareEnumerable < Support::Command
14
14
  ##
15
15
  # @return [Hash{Class => Class}]
16
16
  #
17
- RUBY_CLASS_TO_STEP_AWARE_CLASS_MAP = {
18
- ::Array => Entities::StepAwareEnumerables::Array,
19
- ::Hash => Entities::StepAwareEnumerables::Hash,
20
- ::Set => Entities::StepAwareEnumerables::Set,
21
- ::Enumerator => Entities::StepAwareEnumerables::Enumerator,
22
- ::Enumerator::Lazy => Entities::StepAwareEnumerables::LazyEnumerator,
23
- ::Enumerator::Chain => Entities::StepAwareEnumerables::ChainEnumerator,
24
- ::Enumerator::ArithmeticSequence => Entities::StepAwareEnumerables::ArithmeticSequenceEnumerator
17
+ RUBY_CLASS_TO_SERVICE_AWARE_CLASS_MAP = {
18
+ ::Array => Entities::ServiceAwareEnumerables::Array,
19
+ ::Hash => Entities::ServiceAwareEnumerables::Hash,
20
+ ::Set => Entities::ServiceAwareEnumerables::Set,
21
+ ::Enumerator => Entities::ServiceAwareEnumerables::Enumerator,
22
+ ::Enumerator::Lazy => Entities::ServiceAwareEnumerables::LazyEnumerator,
23
+ ::Enumerator::Chain => Entities::ServiceAwareEnumerables::ChainEnumerator,
24
+ ::Enumerator::ArithmeticSequence => Entities::ServiceAwareEnumerables::ArithmeticSequenceEnumerator
25
25
  }
26
26
 
27
27
  ##
@@ -55,11 +55,11 @@ module ConvenientService
55
55
  end
56
56
 
57
57
  ##
58
- # @return [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Entities::StepAwareEnumerables::Enumerable]
59
- # @raise [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Exceptions::ObjectIsNotEnumerable]
58
+ # @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerable]
59
+ # @raise [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Exceptions::ObjectIsNotEnumerable]
60
60
  #
61
61
  def call
62
- step_aware_enumerable_klass&.new(**attributes) || ::ConvenientService.raise(Exceptions::ObjectIsNotEnumerable.new(object: object))
62
+ service_aware_enumerable_klass&.new(**attributes) || ::ConvenientService.raise(Exceptions::ObjectIsNotEnumerable.new(object: object))
63
63
  end
64
64
 
65
65
  private
@@ -67,16 +67,16 @@ module ConvenientService
67
67
  ##
68
68
  # @return [Class]
69
69
  #
70
- def step_aware_enumerable_klass
71
- klass = RUBY_CLASS_TO_STEP_AWARE_CLASS_MAP[object.class]
70
+ def service_aware_enumerable_klass
71
+ klass = RUBY_CLASS_TO_SERVICE_AWARE_CLASS_MAP[object.class]
72
72
 
73
73
  return klass if klass
74
74
 
75
75
  case object
76
- when ::Enumerator::Lazy then Entities::StepAwareEnumerables::LazyEnumerator
77
- when ::Enumerator::Chain then Entities::StepAwareEnumerables::ChainEnumerator
78
- when ::Enumerator then Entities::StepAwareEnumerables::Enumerator
79
- when ::Enumerable then Entities::StepAwareEnumerables::Enumerable
76
+ when ::Enumerator::Lazy then Entities::ServiceAwareEnumerables::LazyEnumerator
77
+ when ::Enumerator::Chain then Entities::ServiceAwareEnumerables::ChainEnumerator
78
+ when ::Enumerator then Entities::ServiceAwareEnumerables::Enumerator
79
+ when ::Enumerable then Entities::ServiceAwareEnumerables::Enumerable
80
80
  end
81
81
  end
82
82
 
@@ -8,17 +8,17 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module CanHaveStepAwareEnumerables
11
+ module CanHaveServiceAwareEnumerables
12
12
  module Commands
13
- class CastStepAwareEnumerator < Support::Command
13
+ class CastServiceAwareEnumerator < Support::Command
14
14
  ##
15
15
  # @return [Hash{Class => Class}]
16
16
  #
17
- RUBY_CLASS_TO_STEP_AWARE_CLASS_MAP = {
18
- ::Enumerator => Entities::StepAwareEnumerables::Enumerator,
19
- ::Enumerator::Lazy => Entities::StepAwareEnumerables::LazyEnumerator,
20
- ::Enumerator::Chain => Entities::StepAwareEnumerables::ChainEnumerator,
21
- ::Enumerator::ArithmeticSequence => Entities::StepAwareEnumerables::ArithmeticSequenceEnumerator
17
+ RUBY_CLASS_TO_SERVICE_AWARE_CLASS_MAP = {
18
+ ::Enumerator => Entities::ServiceAwareEnumerables::Enumerator,
19
+ ::Enumerator::Lazy => Entities::ServiceAwareEnumerables::LazyEnumerator,
20
+ ::Enumerator::Chain => Entities::ServiceAwareEnumerables::ChainEnumerator,
21
+ ::Enumerator::ArithmeticSequence => Entities::ServiceAwareEnumerables::ArithmeticSequenceEnumerator
22
22
  }
23
23
 
24
24
  ##
@@ -52,11 +52,11 @@ module ConvenientService
52
52
  end
53
53
 
54
54
  ##
55
- # @return [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Entities::StepAwareEnumerables::Enumerable]
56
- # @raise [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Exceptions::ObjectIsNotEnumerator]
55
+ # @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerable]
56
+ # @raise [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Exceptions::ObjectIsNotEnumerator]
57
57
  #
58
58
  def call
59
- step_aware_enumerable_klass&.new(**attributes) || ::ConvenientService.raise(Exceptions::ObjectIsNotEnumerator.new(object: object))
59
+ service_aware_enumerable_klass&.new(**attributes) || ::ConvenientService.raise(Exceptions::ObjectIsNotEnumerator.new(object: object))
60
60
  end
61
61
 
62
62
  private
@@ -64,15 +64,15 @@ module ConvenientService
64
64
  ##
65
65
  # @return [Class]
66
66
  #
67
- def step_aware_enumerable_klass
68
- klass = RUBY_CLASS_TO_STEP_AWARE_CLASS_MAP[object.class]
67
+ def service_aware_enumerable_klass
68
+ klass = RUBY_CLASS_TO_SERVICE_AWARE_CLASS_MAP[object.class]
69
69
 
70
70
  return klass if klass
71
71
 
72
72
  case object
73
- when ::Enumerator::Lazy then Entities::StepAwareEnumerables::LazyEnumerator
74
- when ::Enumerator::Chain then Entities::StepAwareEnumerables::ChainEnumerator
75
- when ::Enumerator then Entities::StepAwareEnumerables::Enumerator
73
+ when ::Enumerator::Lazy then Entities::ServiceAwareEnumerables::LazyEnumerator
74
+ when ::Enumerator::Chain then Entities::ServiceAwareEnumerables::ChainEnumerator
75
+ when ::Enumerator then Entities::ServiceAwareEnumerables::Enumerator
76
76
  end
77
77
  end
78
78
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ # @author Marian Kostyk <mariankostyk13895@gmail.com>
5
+ # @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
6
+ ##
7
+
8
+ require_relative "commands/cast_service_aware_enumerable"
9
+ require_relative "commands/cast_service_aware_enumerator"
@@ -8,31 +8,40 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module CanHaveStepAwareEnumerables
11
+ module CanHaveServiceAwareEnumerables
12
12
  module Concern
13
13
  include Support::Concern
14
14
 
15
+ ##
16
+ # TODO: Implement in `CanBeUsedInServiceAwareEnumerables`.
17
+ #
18
+ # class_methods do
19
+ # def to_service_aware_iteration_block_value
20
+ # end
21
+ # end
22
+ ##
23
+
15
24
  instance_methods do
16
25
  ##
17
26
  # @api public
18
27
  #
19
28
  # @param object [Object] Can be any type.
20
- # @return [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Entities::StepAwareEnumerables::Enumerable]
21
- # @raise [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Exceptions::ObjectIsNotEnumerable]
29
+ # @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerable]
30
+ # @raise [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Exceptions::ObjectIsNotEnumerable]
22
31
  #
23
- def step_aware_enumerable(object)
24
- Commands::CastStepAwareEnumerable.call(object: object, organizer: self)
32
+ def service_aware_enumerable(object)
33
+ Commands::CastServiceAwareEnumerable.call(object: object, organizer: self)
25
34
  end
26
35
 
27
36
  ##
28
37
  # @api public
29
38
  #
30
39
  # @param object [Object] Can be any type.
31
- # @return [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Entities::StepAwareEnumerables::Enumerator]
32
- # @raise [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Exceptions::ObjectIsNotEnumerator]
40
+ # @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerator]
41
+ # @raise [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Exceptions::ObjectIsNotEnumerator]
33
42
  #
34
- def step_aware_enumerator(object)
35
- Commands::CastStepAwareEnumerator.call(object: object, organizer: self)
43
+ def service_aware_enumerator(object)
44
+ Commands::CastServiceAwareEnumerator.call(object: object, organizer: self)
36
45
  end
37
46
  end
38
47
  end
@@ -8,10 +8,10 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module CanHaveStepAwareEnumerables
11
+ module CanHaveServiceAwareEnumerables
12
12
  module Entities
13
- module StepAwareEnumerables
14
- class ArithmeticSequenceEnumerator < Entities::StepAwareEnumerables::Enumerator
13
+ module ServiceAwareEnumerables
14
+ class ArithmeticSequenceEnumerator < Entities::ServiceAwareEnumerables::Enumerator
15
15
  ##
16
16
  # @api private
17
17
  #
@@ -39,11 +39,11 @@ module ConvenientService
39
39
 
40
40
  ##
41
41
  # @param iteration_block [Proc, nil]
42
- # @return [ConvenientService::Service::Plugins::CanHaveStepAwareEnumerables::Entities::StepAwareEnumerables::Enumerable]
42
+ # @return [ConvenientService::Service::Plugins::CanHaveServiceAwareEnumerables::Entities::ServiceAwareEnumerables::Enumerable]
43
43
  #
44
44
  def each(&iteration_block)
45
- with_processing_return_value_as_arithmetic_sequence_enumerator(arguments(&iteration_block)) do |&step_aware_iteration_block|
46
- enumerable.each(&step_aware_iteration_block)
45
+ with_processing_return_value_as_arithmetic_sequence_enumerator(arguments(&iteration_block)) do |&service_aware_iteration_block|
46
+ enumerable.each(&service_aware_iteration_block)
47
47
  end
48
48
  end
49
49
  end
@@ -8,10 +8,10 @@
8
8
  module ConvenientService
9
9
  module Service
10
10
  module Plugins
11
- module CanHaveStepAwareEnumerables
11
+ module CanHaveServiceAwareEnumerables
12
12
  module Entities
13
- module StepAwareEnumerables
14
- class Array < Entities::StepAwareEnumerables::Enumerable
13
+ module ServiceAwareEnumerables
14
+ class Array < Entities::ServiceAwareEnumerables::Enumerable
15
15
  ##
16
16
  # @api private
17
17
  #