convenient_service 0.26.0 → 0.27.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.
- checksums.yaml +4 -4
- data/lib/convenient_service/aliases.rb +0 -11
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_active_model_attribute_assignment/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/assigns_attributes_in_constructor/using_dry_initializer/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/caches_constructor_arguments/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/can_be_copied/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/can_have_callbacks/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/can_have_callbacks/entities/type/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/can_have_not_passed_arguments/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/can_utilize_finite_loop/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_attributes/using_active_model_attributes/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_constructor/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_instance_proxy/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_internals/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_internals/entities/internals/plugins/has_cache/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_j_send_result_duck_short_syntax/concern.rb +1 -1
- data/lib/convenient_service/common/plugins/has_memoization/using_memo_wise/concern.rb +1 -1
- data/lib/convenient_service/config/entities/option.rb +11 -9
- data/lib/convenient_service/config/entities/option_collection.rb +8 -4
- data/lib/convenient_service/core/aliases.rb +50 -0
- data/lib/convenient_service/core/entities/config/commands/build_entity_from_config_option.rb +63 -0
- data/lib/convenient_service/core/entities/config/commands.rb +1 -0
- data/lib/convenient_service/core/entities/config/entities/concerns/usual.rb +50 -0
- data/lib/convenient_service/core/entities/config/entities/concerns.rb +2 -0
- data/lib/convenient_service/core/entities/config/entities/method_middlewares/entities/middlewares/base/concern/class_methods.rb +9 -0
- data/lib/convenient_service/feature/plugins/can_have_entries/concern.rb +1 -1
- data/lib/convenient_service/feature/plugins/can_have_rspec_stubbed_entries/concern.rb +1 -1
- data/lib/convenient_service/feature/plugins/can_have_stubbed_entries/concern.rb +1 -1
- data/lib/convenient_service/feature/plugins/has_amazing_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/feature/plugins/has_awesome_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/feature/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/configs/standard/v1.rb +2 -0
- data/lib/convenient_service/service/configs/standard.rb +11 -6
- data/lib/convenient_service/service/plugins/can_be_called/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_fallbacks/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_handled_exceptions/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_inline_services/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_inline_services/entities/proxy.rb +5 -0
- data/lib/convenient_service/service/plugins/can_have_recalculations/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_rspec_stubbed_results/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_sequential_steps/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_service_aware_enumerables/concern.rb +1 -10
- data/lib/convenient_service/service/plugins/can_have_steps/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/method/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/service/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/commands/cast_params.rb +0 -8
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/commands/extract_params.rb +1 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/concern/instance_methods.rb +0 -11
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_evaluated/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_evaluated/middleware.rb +43 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_evaluated.rb +1 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_method_step/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_service_step/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_strict/concern.rb +35 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_strict/middleware.rb +40 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_strict.rb +9 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_be_used_in_service_aware_enumerables/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/can_have_fallbacks/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_amazing_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_awesome_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins/has_result/middleware.rb +0 -2
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/plugins.rb +1 -0
- data/lib/convenient_service/service/plugins/can_have_steps/entities/step/structs/params.rb +2 -2
- data/lib/convenient_service/service/plugins/can_have_stubbed_results/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/can_not_be_inherited/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_amazing_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_awesome_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_called/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_exception/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_fallback/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_handled_exception/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_from_unhandled_exception/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_own_result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_strict/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_stubbed_result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_be_used_in_service_aware_enumerables/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_checked_status/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_fallbacks/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_parent_result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/can_have_step/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_amazing_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_awesome_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_amazing_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_awesome_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_amazing_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_awesome_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_amazing_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_awesome_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/message/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/can_be_checked/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_amazing_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_awesome_print_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/status/plugins/has_inspect/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_negated_result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_pattern_matching_support/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_active_model_validations/concern.rb +15 -3
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_active_model_validations/middleware.rb +10 -2
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_active_model_validations/no_op_concern.rb +116 -0
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_active_model_validations.rb +1 -0
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation/concern.rb +19 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation/middleware.rb +10 -2
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation/no_op_concern.rb +43 -0
- data/lib/convenient_service/service/plugins/has_j_send_result_params_validations/using_dry_validation.rb +1 -0
- data/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_j_send_result_status_check_short_syntax/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_negated_j_send_result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_negated_result/concern.rb +1 -1
- data/lib/convenient_service/service/plugins/has_result/concern.rb +1 -1
- data/lib/convenient_service/version.rb +1 -1
- metadata +9 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2720d14bda6c640d8c9e951311f89352f93b8b02018dd6bda721741b2148d542
|
|
4
|
+
data.tar.gz: 443f18f104077ddd7c6a2c87d30ff77c6f34cc267afcbf814a8de3d3f2aff1a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27b25614536893aba9bc8f785b5360ba514bc0a23c0dafcf5f8e56df27d698f00a7791595e5fc4b8c0df9e4822fbc9520444d94caebf61926cd8e6644922705b
|
|
7
|
+
data.tar.gz: 90ab1ac704bd5094b6b4b947fe0d73be1dc45da6dc19432ebbe388782027b0cc025325e07f29bdc8d0379dd78411d206c021b090729cbd568353f8de006ba4c8
|
|
@@ -62,17 +62,6 @@ module ConvenientService
|
|
|
62
62
|
#
|
|
63
63
|
Command = ::ConvenientService::Support::Command
|
|
64
64
|
|
|
65
|
-
##
|
|
66
|
-
# Convenient Service concern (Like Rails concern, but with some customizations).
|
|
67
|
-
#
|
|
68
|
-
# @api public
|
|
69
|
-
# @since 1.0.0
|
|
70
|
-
# @return [Module]
|
|
71
|
-
#
|
|
72
|
-
# @note Expected to be used from Convenient Service plugins.
|
|
73
|
-
#
|
|
74
|
-
Concern = ::ConvenientService::Support::Concern
|
|
75
|
-
|
|
76
65
|
##
|
|
77
66
|
# Convenient Service dependency container.
|
|
78
67
|
#
|
|
@@ -11,7 +11,7 @@ module ConvenientService
|
|
|
11
11
|
module AssignsAttributesInConstructor
|
|
12
12
|
module UsingActiveModelAttributeAssignment
|
|
13
13
|
module Concern
|
|
14
|
-
include
|
|
14
|
+
include ::ConvenientService::Concern
|
|
15
15
|
|
|
16
16
|
included do |service_class|
|
|
17
17
|
service_class.include ::ActiveModel::AttributeAssignment
|
data/lib/convenient_service/common/plugins/has_attributes/using_active_model_attributes/concern.rb
CHANGED
|
@@ -11,7 +11,7 @@ module ConvenientService
|
|
|
11
11
|
module HasAttributes
|
|
12
12
|
module UsingActiveModelAttributes
|
|
13
13
|
module Concern
|
|
14
|
-
include
|
|
14
|
+
include ::ConvenientService::Concern
|
|
15
15
|
|
|
16
16
|
included do |service_class|
|
|
17
17
|
service_class.include Patches::ActiveModelAttributes
|
|
@@ -16,21 +16,26 @@ module ConvenientService
|
|
|
16
16
|
attr_reader :name
|
|
17
17
|
|
|
18
18
|
##
|
|
19
|
-
# @!attribute [r]
|
|
19
|
+
# @!attribute [r] details
|
|
20
20
|
# @return [Hash{Symbol => Object}]
|
|
21
21
|
#
|
|
22
|
-
attr_reader :
|
|
22
|
+
attr_reader :details
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# @return [Hash{Symbol => Object}]
|
|
26
|
+
#
|
|
27
|
+
alias_method :data, :details
|
|
23
28
|
|
|
24
29
|
##
|
|
25
30
|
# @param name [Symbol]
|
|
26
31
|
# @param enabled [Object] Can be any type.
|
|
27
|
-
# @param
|
|
32
|
+
# @param details [Hash{Symbol => Object}]
|
|
28
33
|
# @return [void]
|
|
29
34
|
#
|
|
30
|
-
def initialize(name:, enabled: false, **
|
|
35
|
+
def initialize(name:, enabled: false, **details)
|
|
31
36
|
@name = name
|
|
32
37
|
@enabled = Utils.to_bool(enabled)
|
|
33
|
-
@
|
|
38
|
+
@details = details
|
|
34
39
|
end
|
|
35
40
|
|
|
36
41
|
##
|
|
@@ -44,15 +49,12 @@ module ConvenientService
|
|
|
44
49
|
# @param other [Object] Can be any type.
|
|
45
50
|
# @return [Boolean, nil]
|
|
46
51
|
#
|
|
47
|
-
# @internal
|
|
48
|
-
# TODO: Tests.
|
|
49
|
-
#
|
|
50
52
|
def ==(other)
|
|
51
53
|
return unless other.instance_of?(self.class)
|
|
52
54
|
|
|
53
55
|
return false if name != other.name
|
|
54
56
|
return false if enabled != other.enabled
|
|
55
|
-
return false if
|
|
57
|
+
return false if details != other.details
|
|
56
58
|
|
|
57
59
|
true
|
|
58
60
|
end
|
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
module ConvenientService
|
|
9
9
|
module Config
|
|
10
10
|
module Entities
|
|
11
|
-
##
|
|
12
|
-
# @internal
|
|
13
|
-
# TODO: Specs.
|
|
14
|
-
#
|
|
15
11
|
class OptionCollection
|
|
16
12
|
##
|
|
17
13
|
# @!attribute [r] options
|
|
@@ -65,6 +61,14 @@ module ConvenientService
|
|
|
65
61
|
options[name].enabled?
|
|
66
62
|
end
|
|
67
63
|
|
|
64
|
+
##
|
|
65
|
+
# @param names [Array<Symbol>]
|
|
66
|
+
# @return [Boolean]
|
|
67
|
+
#
|
|
68
|
+
def any_enabled?(*names)
|
|
69
|
+
names.any? { |name| enabled?(name) }
|
|
70
|
+
end
|
|
71
|
+
|
|
68
72
|
##
|
|
69
73
|
# @param name [Symbol]
|
|
70
74
|
# @return [Boolean]
|
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
##
|
|
7
7
|
|
|
8
8
|
module ConvenientService
|
|
9
|
+
##
|
|
10
|
+
# Convenient Service concern (Like Rails concern, but with some customizations).
|
|
11
|
+
#
|
|
12
|
+
# @api public
|
|
13
|
+
# @since 1.0.0
|
|
14
|
+
# @return [Module]
|
|
15
|
+
#
|
|
16
|
+
# @note Expected to be used from Convenient Service plugins.
|
|
17
|
+
#
|
|
18
|
+
Concern = ::ConvenientService::Core::Entities::Config::Entities::Concerns::Usual
|
|
19
|
+
|
|
9
20
|
##
|
|
10
21
|
# Base class for concern middlewares.
|
|
11
22
|
#
|
|
@@ -94,4 +105,43 @@ module ConvenientService
|
|
|
94
105
|
# # => <Service::Result status: :success>
|
|
95
106
|
#
|
|
96
107
|
MethodChainMiddleware = ::ConvenientService::Core::Entities::Config::Entities::MethodMiddlewares::Entities::Middlewares::Chain
|
|
108
|
+
|
|
109
|
+
##
|
|
110
|
+
# Alias to base class for method middlewares using `chain.next`.
|
|
111
|
+
#
|
|
112
|
+
# @api public
|
|
113
|
+
# @since 1.0.0
|
|
114
|
+
# @return [Class]
|
|
115
|
+
#
|
|
116
|
+
# @example Common usage.
|
|
117
|
+
# class Middleware < ConvenientService::MethodMiddleware
|
|
118
|
+
# def next(*args, **kwargs, &block)
|
|
119
|
+
# p [args, kwargs, block]
|
|
120
|
+
#
|
|
121
|
+
# value = chain.next(*args, **kwargs, &block)
|
|
122
|
+
#
|
|
123
|
+
# p value
|
|
124
|
+
#
|
|
125
|
+
# value
|
|
126
|
+
# end
|
|
127
|
+
# end
|
|
128
|
+
#
|
|
129
|
+
# class Service
|
|
130
|
+
# include ConvenientService::Standard::Config
|
|
131
|
+
#
|
|
132
|
+
# middlewares :result do
|
|
133
|
+
# insert_before 0, Middleware
|
|
134
|
+
# end
|
|
135
|
+
#
|
|
136
|
+
# def result
|
|
137
|
+
# success
|
|
138
|
+
# end
|
|
139
|
+
# end
|
|
140
|
+
#
|
|
141
|
+
# Service.result
|
|
142
|
+
# # {args: [], kwargs: {}, block: nil, entity: <Service>, method: :result}
|
|
143
|
+
# # <Service::Result status: :success>
|
|
144
|
+
# # => <Service::Result status: :success>
|
|
145
|
+
#
|
|
146
|
+
Middleware = MethodChainMiddleware
|
|
97
147
|
end
|
|
@@ -0,0 +1,63 @@
|
|
|
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 Core
|
|
10
|
+
module Entities
|
|
11
|
+
class Config
|
|
12
|
+
module Commands
|
|
13
|
+
class BuildEntityFromConfigOption < Support::Command
|
|
14
|
+
##
|
|
15
|
+
# @!attribute [r] base_entity
|
|
16
|
+
# @return [#with]
|
|
17
|
+
#
|
|
18
|
+
attr_reader :base_entity
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# @!attribute [r] config
|
|
22
|
+
# @return [ConvenientService::Config::Entities::Option]
|
|
23
|
+
#
|
|
24
|
+
attr_reader :option
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# @!attribute [r] detail_keys
|
|
28
|
+
# @return [Array<Symbol>]
|
|
29
|
+
#
|
|
30
|
+
attr_reader :detail_keys
|
|
31
|
+
|
|
32
|
+
##
|
|
33
|
+
# @param base_entity [#with]
|
|
34
|
+
# @param option [ConvenientService::Config::Entities::Option]
|
|
35
|
+
# @param detail_keys [Array<Symbol>]
|
|
36
|
+
# @return [void]
|
|
37
|
+
#
|
|
38
|
+
def initialize(base_entity:, option:, detail_keys:)
|
|
39
|
+
@base_entity = base_entity
|
|
40
|
+
@option = option
|
|
41
|
+
@detail_keys = detail_keys
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# @return [Object] Can be any type.
|
|
46
|
+
#
|
|
47
|
+
def call
|
|
48
|
+
return base_entity unless option
|
|
49
|
+
return base_entity if option.data.empty?
|
|
50
|
+
return base_entity if detail_keys.empty?
|
|
51
|
+
|
|
52
|
+
data_values = option.data.slice(*detail_keys)
|
|
53
|
+
|
|
54
|
+
return base_entity if data_values.empty?
|
|
55
|
+
|
|
56
|
+
base_entity.with(**data_values)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# @license LGPLv3 <https://www.gnu.org/licenses/lgpl-3.0.html>
|
|
6
6
|
##
|
|
7
7
|
|
|
8
|
+
require_relative "commands/build_entity_from_config_option"
|
|
8
9
|
require_relative "commands/create_entity_class"
|
|
9
10
|
require_relative "commands/find_entity_class"
|
|
10
11
|
require_relative "commands/find_or_create_entity_class"
|
|
@@ -0,0 +1,50 @@
|
|
|
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 Core
|
|
10
|
+
module Entities
|
|
11
|
+
class Config
|
|
12
|
+
module Entities
|
|
13
|
+
class Concerns
|
|
14
|
+
module Usual
|
|
15
|
+
class << self
|
|
16
|
+
##
|
|
17
|
+
# @param mod [Module]
|
|
18
|
+
# @return [void]
|
|
19
|
+
#
|
|
20
|
+
def included(mod)
|
|
21
|
+
mod.extend Dependencies::Extractions::ActiveSupportConcern::Concern
|
|
22
|
+
|
|
23
|
+
mod.module_exec do
|
|
24
|
+
class << self
|
|
25
|
+
##
|
|
26
|
+
# @param option [ConvenientService::Config::Entities::Option]
|
|
27
|
+
# @param detail_keys [Array<Symbol>]
|
|
28
|
+
# @return [ConvenientService::Core::Entities::Config::Entities::MethodMiddlewares::Entities::Middlewares::Base]
|
|
29
|
+
#
|
|
30
|
+
def from(option, *detail_keys)
|
|
31
|
+
::ConvenientService::Core::Entities::Config::Commands::BuildEntityFromConfigOption.call(base_entity: self, option: option, detail_keys: detail_keys)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# @return [ConvenientService::Core::Entities::Config::Entities::MethodMiddlewares::Entities::MiddlewareCreators::With]
|
|
36
|
+
#
|
|
37
|
+
def with(...)
|
|
38
|
+
self
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -25,6 +25,15 @@ module ConvenientService
|
|
|
25
25
|
class Base
|
|
26
26
|
module Concern
|
|
27
27
|
module ClassMethods
|
|
28
|
+
##
|
|
29
|
+
# @param option [ConvenientService::Config::Entities::Option]
|
|
30
|
+
# @param detail_keys [Array<Symbol>]
|
|
31
|
+
# @return [ConvenientService::Core::Entities::Config::Entities::MethodMiddlewares::Entities::Middlewares::Base]
|
|
32
|
+
#
|
|
33
|
+
def from(option, *detail_keys)
|
|
34
|
+
::ConvenientService::Core::Entities::Config::Commands::BuildEntityFromConfigOption.call(base_entity: self, option: option, detail_keys: detail_keys)
|
|
35
|
+
end
|
|
36
|
+
|
|
28
37
|
##
|
|
29
38
|
# @return [ConvenientService::Core::Entities::Config::Entities::MethodMiddlewares::Entities::MiddlewareCreators::With]
|
|
30
39
|
#
|
|
@@ -19,6 +19,7 @@ module ConvenientService
|
|
|
19
19
|
[
|
|
20
20
|
:essential,
|
|
21
21
|
:callbacks,
|
|
22
|
+
:strictness,
|
|
22
23
|
:inspect,
|
|
23
24
|
:recalculation,
|
|
24
25
|
:result_parents_trace,
|
|
@@ -36,6 +37,7 @@ module ConvenientService
|
|
|
36
37
|
[
|
|
37
38
|
:essential,
|
|
38
39
|
:callbacks,
|
|
40
|
+
:strictness,
|
|
39
41
|
:inspect,
|
|
40
42
|
:recalculation,
|
|
41
43
|
:result_parents_trace,
|
|
@@ -24,6 +24,7 @@ module ConvenientService
|
|
|
24
24
|
:fallbacks,
|
|
25
25
|
:rollbacks,
|
|
26
26
|
:fault_tolerance,
|
|
27
|
+
:strictness,
|
|
27
28
|
:inspect,
|
|
28
29
|
:recalculation,
|
|
29
30
|
:result_parents_trace,
|
|
@@ -54,6 +55,7 @@ module ConvenientService
|
|
|
54
55
|
:essential,
|
|
55
56
|
:callbacks,
|
|
56
57
|
:fallbacks,
|
|
58
|
+
:strictness,
|
|
57
59
|
:inspect,
|
|
58
60
|
:recalculation,
|
|
59
61
|
:result_parents_trace,
|
|
@@ -110,8 +112,8 @@ module ConvenientService
|
|
|
110
112
|
use ConvenientService::Plugins::Common::AssignsAttributesInConstructor::UsingActiveModelAttributeAssignment::Concern if options.enabled?(:active_model_attribute_assignment)
|
|
111
113
|
use ConvenientService::Plugins::Common::AssignsAttributesInConstructor::UsingDryInitializer::Concern if options.enabled?(:dry_initializer)
|
|
112
114
|
use ConvenientService::Plugins::Common::HasAttributes::UsingActiveModelAttributes::Concern if options.enabled?(:active_model_attributes)
|
|
113
|
-
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingActiveModelValidations::Concern if options.enabled?(:active_model_validations)
|
|
114
|
-
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingDryValidation::Concern if options.enabled?(:dry_validation)
|
|
115
|
+
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingActiveModelValidations::Concern.from(options[:active_model_validations], :skip_validations) if options.enabled?(:active_model_validations)
|
|
116
|
+
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingDryValidation::Concern.from(options[:dry_validation], :skip_validations) if options.enabled?(:dry_validation)
|
|
115
117
|
use ConvenientService::Plugins::Common::HasMemoization::UsingMemoWise::Concern if options.enabled?(:memo_wise)
|
|
116
118
|
use ConvenientService::Plugins::Common::CanHaveNotPassedArguments::Concern if options.enabled?(:not_passed_arguments)
|
|
117
119
|
use ConvenientService::Plugins::Common::CanUtilizeFiniteLoop::Concern if options.enabled?(:finite_loop)
|
|
@@ -137,8 +139,8 @@ module ConvenientService
|
|
|
137
139
|
use ConvenientService::Plugins::Service::RescuesResultUnhandledExceptions::Middleware if options.enabled?(:fault_tolerance)
|
|
138
140
|
use ConvenientService::Plugins::Common::CleansExceptionBacktrace::Middleware if options.enabled?(:backtrace_cleaner)
|
|
139
141
|
use ConvenientService::Plugins::Common::TriesToConvertResultDuckToResult::Middleware if options.enabled?(:duck_typing)
|
|
140
|
-
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingActiveModelValidations::Middleware if options.enabled?(:active_model_validations)
|
|
141
|
-
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingDryValidation::Middleware if options.enabled?(:dry_validation)
|
|
142
|
+
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingActiveModelValidations::Middleware.from(options[:active_model_validations], :status, :skip_validations) if options.enabled?(:active_model_validations)
|
|
143
|
+
use ConvenientService::Plugins::Service::HasJSendResultParamsValidations::UsingDryValidation::Middleware.from(options[:dry_validation], :status, :skip_validations) if options.enabled?(:dry_validation)
|
|
142
144
|
use ConvenientService::Plugins::Service::CanHaveConnectedSteps::Middleware if options.enabled?(:essential)
|
|
143
145
|
end
|
|
144
146
|
|
|
@@ -227,7 +229,7 @@ module ConvenientService
|
|
|
227
229
|
use ConvenientService::Plugins::Result::HasJSendStatusAndAttributes::Concern if options.enabled?(:essential)
|
|
228
230
|
use ConvenientService::Plugins::Result::CanHaveStep::Concern if options.enabled?(:essential)
|
|
229
231
|
use ConvenientService::Plugins::Result::CanBeCalled::Concern if options.enabled?(:essential)
|
|
230
|
-
use ConvenientService::Plugins::Result::CanBeStrict::Concern if options.enabled?(:
|
|
232
|
+
use ConvenientService::Plugins::Result::CanBeStrict::Concern if options.enabled?(:strictness)
|
|
231
233
|
use ConvenientService::Plugins::Result::CanBeUsedInServiceAwareEnumerables::Concern if options.enabled?(:essential)
|
|
232
234
|
use ConvenientService::Plugins::Result::HasNegatedResult::Concern if options.enabled?(:essential)
|
|
233
235
|
use ConvenientService::Plugins::Result::HasPatternMatchingSupport::Concern if options.enabled?(:essential)
|
|
@@ -346,12 +348,13 @@ module ConvenientService
|
|
|
346
348
|
concerns do
|
|
347
349
|
use ConvenientService::Plugins::Common::HasInternals::Concern if options.enabled?(:essential)
|
|
348
350
|
use ConvenientService::Plugins::Step::HasResult::Concern if options.enabled?(:essential)
|
|
349
|
-
use ConvenientService::Plugins::Step::CanBeEvaluated::Concern if options.enabled?(:essential)
|
|
350
351
|
use ConvenientService::Plugins::Step::CanBeServiceStep::Concern if options.enabled?(:essential)
|
|
351
352
|
use ConvenientService::Plugins::Step::CanBeMethodStep::Concern if options.enabled?(:essential)
|
|
352
353
|
use ConvenientService::Plugins::Step::CanBeUsedInServiceAwareEnumerables::Concern if options.enabled?(:essential)
|
|
353
354
|
use ConvenientService::Plugins::Common::CanHaveCallbacks::Concern if options.enabled?(:callbacks)
|
|
354
355
|
use ConvenientService::Plugins::Step::CanHaveFallbacks::Concern if options.enabled?(:fallbacks)
|
|
356
|
+
use ConvenientService::Plugins::Step::CanBeStrict::Concern if options.enabled?(:strictness)
|
|
357
|
+
use ConvenientService::Plugins::Step::CanBeEvaluated::Concern if options.any_enabled?(:rollbacks, :exception_services_trace)
|
|
355
358
|
use ConvenientService::Plugins::Step::HasInspect::Concern if options.enabled?(:inspect)
|
|
356
359
|
use ConvenientService::Plugins::Step::HasAwesomePrintInspect::Concern if options.enabled?(:awesome_print_inspect)
|
|
357
360
|
use ConvenientService::Plugins::Step::HasAmazingPrintInspect::Concern if options.enabled?(:amazing_print_inspect)
|
|
@@ -360,6 +363,8 @@ module ConvenientService
|
|
|
360
363
|
|
|
361
364
|
middlewares :result do
|
|
362
365
|
use ConvenientService::Plugins::Common::CachesReturnValue::Middleware if options.enabled?(:per_instance_caching)
|
|
366
|
+
use ConvenientService::Plugins::Step::CanBeStrict::Middleware if options.enabled?(:strictness)
|
|
367
|
+
use ConvenientService::Plugins::Step::CanBeEvaluated::Middleware if options.any_enabled?(:rollbacks, :exception_services_trace)
|
|
363
368
|
use ConvenientService::Plugins::Step::HasResult::Middleware if options.enabled?(:essential)
|
|
364
369
|
use ConvenientService::Plugins::Step::CanHaveParentResult::Middleware if options.enabled?(:result_parents_trace)
|
|
365
370
|
use ConvenientService::Plugins::Step::CanHaveFallbacks::Middleware.with(fallback_true_status: :failure) if options.enabled?(:fallbacks)
|