servactory 2.5.0.rc5 → 2.5.0.rc7
Sign up to get free protection for your applications and to get access to all the features.
- 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/tool_kit/dynamic_options/format.rb +8 -0
- data/lib/servactory/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf2fb8cd65c29e7a289a894ab2e76967b0bbea248d401242f4585319499e9ac1
|
4
|
+
data.tar.gz: 6abc26c7f3794bb4d2c25c32ac0e72551e18db64579f5b12973e9631cf799742
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f56bf7de98905ca33b42d08ad34aeaa4572b36292b169c404761f195ca69679fa19789f85c19b9d314bbdbe40ff988062072b4e7dc7740671af1208ae56fc0f
|
7
|
+
data.tar.gz: 4c2497680b3dba26064869548dff8aae78de2abd59a97b80c717a8df40c0a184ddad22ae2e9293d23200d9bf7395f5b661fbbd29b847c68f0832656f972528c7
|
@@ -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
|
########################################################################
|
@@ -21,6 +21,14 @@ module Servactory
|
|
21
21
|
pattern: /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,16}$/,
|
22
22
|
validator: ->(value:) { value.present? }
|
23
23
|
},
|
24
|
+
duration: {
|
25
|
+
pattern: nil,
|
26
|
+
validator: lambda do |value:|
|
27
|
+
ActiveSupport::Duration.parse(value) and return true
|
28
|
+
rescue ActiveSupport::Duration::ISO8601Parser::ParsingError
|
29
|
+
false
|
30
|
+
end
|
31
|
+
},
|
24
32
|
date: {
|
25
33
|
pattern: nil,
|
26
34
|
validator: lambda do |value:|
|
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.0.
|
4
|
+
version: 2.5.0.rc7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|