servactory 2.5.0.rc5 → 2.5.0.rc6
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/generators/servactory/templates/services/application_service/base.rb +2 -0
- data/lib/servactory/configuration/dsl.rb +2 -0
- data/lib/servactory/configuration/factory.rb +17 -0
- data/lib/servactory/configuration/setup.rb +8 -1
- data/lib/servactory/context/workspace/inputs.rb +3 -2
- data/lib/servactory/context/workspace/internals.rb +3 -3
- data/lib/servactory/context/workspace/outputs.rb +3 -3
- data/lib/servactory/result.rb +10 -3
- data/lib/servactory/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe966e4418033cec85b4d0f335a4cbfaefc5fe65e2c510bfec9a755601a088c7
|
4
|
+
data.tar.gz: b6bf04ea33fc1e3f5307406ea848fb2fb65117ec697339c99b581796ff4f568e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0847386548d522669a7faf2ad1fc86a41a10cec8d19b1f7c1263b8b842210b236f0c84f1fc9e1bedbd196594031b0e79e20cbaece5e5b5b2bde6efcd458ae14c'
|
7
|
+
data.tar.gz: d8bf8ebff755faebe4d7ccdefe9ab412a79e33b6b9ab888537d1a0cae7b19e78fa57b36d4e387cccdc451c37f1a2443ef5d09b6eb79118526145a8b1491581f8
|
@@ -29,6 +29,8 @@ module Servactory
|
|
29
29
|
child.config.action_aliases = config.action_aliases
|
30
30
|
child.config.action_shortcuts = config.action_shortcuts
|
31
31
|
child.config.action_rescue_handlers = config.action_rescue_handlers
|
32
|
+
|
33
|
+
child.config.predicate_methods_enabled = config.predicate_methods_enabled
|
32
34
|
end
|
33
35
|
|
34
36
|
def config
|
@@ -97,6 +97,12 @@ module Servactory
|
|
97
97
|
@config.action_shortcuts.merge(action_shortcuts)
|
98
98
|
end
|
99
99
|
|
100
|
+
def predicate_methods_enabled(flag)
|
101
|
+
return @config.predicate_methods_enabled = flag if boolean?(flag)
|
102
|
+
|
103
|
+
raise_error_about_wrong_predicate_methods_enabled_with(:predicate_methods_enabled, flag)
|
104
|
+
end
|
105
|
+
|
100
106
|
private
|
101
107
|
|
102
108
|
# def action_rescue_handlers(action_rescue_handlers)
|
@@ -111,6 +117,10 @@ module Servactory
|
|
111
117
|
value.is_a?(Class) && value <= Servactory::Result
|
112
118
|
end
|
113
119
|
|
120
|
+
def boolean?(value)
|
121
|
+
value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
122
|
+
end
|
123
|
+
|
114
124
|
##########################################################################
|
115
125
|
|
116
126
|
def raise_error_about_wrong_exception_class_with(config_name, value)
|
@@ -126,6 +136,13 @@ module Servactory
|
|
126
136
|
"The `#{value}` value must be a subclass of `Servactory::Result`. " \
|
127
137
|
"See configuration example here: https://servactory.com/guide/configuration"
|
128
138
|
end
|
139
|
+
|
140
|
+
def raise_error_about_wrong_predicate_methods_enabled_with(config_name, value)
|
141
|
+
raise ArgumentError,
|
142
|
+
"Error in `#{config_name}` configuration. " \
|
143
|
+
"The `#{value}` value must be `TrueClass` or `FalseClass`. " \
|
144
|
+
"See configuration example here: https://servactory.com/guide/configuration"
|
145
|
+
end
|
129
146
|
end
|
130
147
|
end
|
131
148
|
end
|
@@ -16,7 +16,8 @@ module Servactory
|
|
16
16
|
:output_option_helpers,
|
17
17
|
:action_aliases,
|
18
18
|
:action_shortcuts,
|
19
|
-
:action_rescue_handlers
|
19
|
+
:action_rescue_handlers,
|
20
|
+
:predicate_methods_enabled
|
20
21
|
|
21
22
|
def initialize # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
22
23
|
@input_exception_class = Servactory::Exceptions::Input
|
@@ -46,6 +47,12 @@ module Servactory
|
|
46
47
|
@action_aliases = Servactory::Actions::Aliases::Collection.new
|
47
48
|
@action_shortcuts = Servactory::Actions::Shortcuts::Collection.new
|
48
49
|
@action_rescue_handlers = Servactory::Actions::RescueHandlers::Collection.new
|
50
|
+
|
51
|
+
@predicate_methods_enabled = true
|
52
|
+
end
|
53
|
+
|
54
|
+
def predicate_methods_enabled?
|
55
|
+
@predicate_methods_enabled
|
49
56
|
end
|
50
57
|
|
51
58
|
private
|
@@ -43,7 +43,8 @@ module Servactory
|
|
43
43
|
|
44
44
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
|
45
45
|
def getter_with(name:, &block)
|
46
|
-
input_name = name.to_s.chomp("?").to_sym
|
46
|
+
input_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
|
47
|
+
|
47
48
|
input = @collection_of_inputs.find_by(name: input_name)
|
48
49
|
|
49
50
|
return yield if input.nil?
|
@@ -58,7 +59,7 @@ module Servactory
|
|
58
59
|
input_prepare = input.prepare.fetch(:in, nil)
|
59
60
|
input_value = input_prepare.call(value: input_value) if input_prepare.present?
|
60
61
|
|
61
|
-
if name.to_s.end_with?("?")
|
62
|
+
if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
|
62
63
|
Servactory::Utils.query_attribute(input_value)
|
63
64
|
else
|
64
65
|
input_value
|
@@ -53,15 +53,15 @@ module Servactory
|
|
53
53
|
@context.send(:servactory_service_store).assign_internal(internal.name, value)
|
54
54
|
end
|
55
55
|
|
56
|
-
def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
|
57
|
-
internal_name = name.to_s.chomp("?").to_sym
|
56
|
+
def getter_with(name:, &block) # rubocop:disable Metrics/AbcSize, Lint/UnusedMethodArgument
|
57
|
+
internal_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
|
58
58
|
internal = @collection_of_internals.find_by(name: internal_name)
|
59
59
|
|
60
60
|
return yield if internal.nil?
|
61
61
|
|
62
62
|
internal_value = @context.send(:servactory_service_store).fetch_internal(internal.name)
|
63
63
|
|
64
|
-
if name.to_s.end_with?("?")
|
64
|
+
if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
|
65
65
|
Servactory::Utils.query_attribute(internal_value)
|
66
66
|
else
|
67
67
|
internal_value
|
@@ -53,15 +53,15 @@ module Servactory
|
|
53
53
|
@context.send(:servactory_service_store).assign_output(output.name, value)
|
54
54
|
end
|
55
55
|
|
56
|
-
def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
|
57
|
-
output_name = name.to_s.chomp("?").to_sym
|
56
|
+
def getter_with(name:, &block) # rubocop:disable Metrics/AbcSize, Lint/UnusedMethodArgument
|
57
|
+
output_name = @context.class.config.predicate_methods_enabled? ? name.to_s.chomp("?").to_sym : name
|
58
58
|
output = @collection_of_outputs.find_by(name: output_name)
|
59
59
|
|
60
60
|
return yield if output.nil?
|
61
61
|
|
62
62
|
output_value = @context.send(:servactory_service_store).fetch_output(output.name)
|
63
63
|
|
64
|
-
if name.to_s.end_with?("?")
|
64
|
+
if name.to_s.end_with?("?") && @context.class.config.predicate_methods_enabled?
|
65
65
|
Servactory::Utils.query_attribute(output_value)
|
66
66
|
else
|
67
67
|
output_value
|
data/lib/servactory/result.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
module Servactory
|
4
4
|
class Result
|
5
5
|
class Outputs
|
6
|
-
def initialize(outputs)
|
6
|
+
def initialize(outputs:, predicate_methods_enabled:)
|
7
7
|
outputs.each_pair do |key, value|
|
8
|
-
define_singleton_method(:"#{key}?") { Servactory::Utils.query_attribute(value) }
|
8
|
+
define_singleton_method(:"#{key}?") { Servactory::Utils.query_attribute(value) } if predicate_methods_enabled
|
9
9
|
define_singleton_method(key) { value }
|
10
10
|
end
|
11
11
|
end
|
@@ -104,7 +104,14 @@ module Servactory
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def outputs
|
107
|
-
@outputs ||= Outputs.new(
|
107
|
+
@outputs ||= Outputs.new(
|
108
|
+
outputs: @context.send(:servactory_service_store).outputs,
|
109
|
+
predicate_methods_enabled: if @context.is_a?(Servactory::TestKit::Result)
|
110
|
+
true
|
111
|
+
else
|
112
|
+
@context.class.config.predicate_methods_enabled?
|
113
|
+
end
|
114
|
+
)
|
108
115
|
end
|
109
116
|
|
110
117
|
########################################################################
|
data/lib/servactory/version.rb
CHANGED