servactory 1.6.8 → 1.6.10
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 247691253c0f26610c8586f31425e2ac33f4b137f67ba68642affb4e3411d306
|
4
|
+
data.tar.gz: 5050386caa9eaa939eb637f177978085bf02e5a035741e9c372216bc9886276e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd2eea84309d84773e035600d143183add63818e7e77ba985d79f7b7b36c4caae9b22f8dc58422a3e2ed7e4c635a09d2beed2f465e639c3c87739034354ffe9a
|
7
|
+
data.tar.gz: a4e7919863596451fa78fdcca4e763906a65d3dd8f5f4b8fe041c98ef7ea3de5a64db7bcdcc059a447ba926810de275ddcf3c3cd6a6315ab9d4de571630852fb
|
@@ -63,6 +63,7 @@ module Servactory
|
|
63
63
|
add_must_option_with(options)
|
64
64
|
|
65
65
|
# Check Class: nil
|
66
|
+
add_prepare_option_with(options)
|
66
67
|
add_internal_option_with(options)
|
67
68
|
end
|
68
69
|
|
@@ -180,6 +181,29 @@ module Servactory
|
|
180
181
|
)
|
181
182
|
end
|
182
183
|
|
184
|
+
def add_prepare_option_with(options)
|
185
|
+
collection_of_options << Option.new(
|
186
|
+
name: :prepare,
|
187
|
+
input: self,
|
188
|
+
validation_class: nil,
|
189
|
+
define_input_methods: [
|
190
|
+
DefineInputMethod.new(
|
191
|
+
name: :prepare_present?,
|
192
|
+
content: ->(value:) { value[:in].present? }
|
193
|
+
)
|
194
|
+
],
|
195
|
+
define_input_conflicts: [
|
196
|
+
DefineInputConflict.new(content: -> { :prepare_vs_array if prepare_present? && array? }),
|
197
|
+
DefineInputConflict.new(content: -> { :prepare_vs_inclusion if prepare_present? && inclusion_present? }),
|
198
|
+
DefineInputConflict.new(content: -> { :prepare_vs_must if prepare_present? && must_present? })
|
199
|
+
],
|
200
|
+
need_for_checks: false,
|
201
|
+
value_key: :in,
|
202
|
+
value_fallback: false,
|
203
|
+
**options
|
204
|
+
)
|
205
|
+
end
|
206
|
+
|
183
207
|
def add_internal_option_with(options) # rubocop:disable Metrics/MethodLength
|
184
208
|
collection_of_options << Option.new(
|
185
209
|
name: :internal,
|
@@ -31,6 +31,9 @@ module Servactory
|
|
31
31
|
input_value = @incoming_arguments.fetch(input.name, nil)
|
32
32
|
input_value = input.default if input.optional? && input_value.blank?
|
33
33
|
|
34
|
+
input_prepare = input.prepare.fetch(:in, nil)
|
35
|
+
input_value = input_prepare.call(value: input_value) if input_prepare.present?
|
36
|
+
|
34
37
|
if input.internal?
|
35
38
|
@internal_variables[input.name] = input_value
|
36
39
|
else
|
@@ -38,6 +38,12 @@ module Servactory
|
|
38
38
|
@current_stage.rollback = rollback
|
39
39
|
end
|
40
40
|
|
41
|
+
def only_if(condition)
|
42
|
+
return if @current_stage.blank?
|
43
|
+
|
44
|
+
@current_stage.condition = condition
|
45
|
+
end
|
46
|
+
|
41
47
|
def make(name, position: nil, **options)
|
42
48
|
position = position.presence || next_position
|
43
49
|
|
@@ -5,12 +5,14 @@ module Servactory
|
|
5
5
|
class Stage
|
6
6
|
attr_accessor :position,
|
7
7
|
:wrapper,
|
8
|
-
:rollback
|
8
|
+
:rollback,
|
9
|
+
:condition
|
9
10
|
|
10
|
-
def initialize(position:, wrapper: nil, rollback: nil)
|
11
|
+
def initialize(position:, wrapper: nil, rollback: nil, condition: nil)
|
11
12
|
@position = position
|
12
13
|
@wrapper = wrapper
|
13
14
|
@rollback = rollback
|
15
|
+
@condition = condition
|
14
16
|
end
|
15
17
|
|
16
18
|
def next_method_position
|
@@ -33,6 +33,8 @@ module Servactory
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def call_stage(stage)
|
36
|
+
return if unnecessary_for_stage?(stage)
|
37
|
+
|
36
38
|
wrapper = stage.wrapper
|
37
39
|
rollback = stage.rollback
|
38
40
|
methods = stage.methods.sorted_by_position
|
@@ -52,13 +54,23 @@ module Servactory
|
|
52
54
|
|
53
55
|
def call_methods(methods)
|
54
56
|
methods.each do |make_method|
|
55
|
-
next if
|
57
|
+
next if unnecessary_for_make?(make_method)
|
56
58
|
|
57
59
|
context.send(make_method.name)
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
def
|
63
|
+
def unnecessary_for_stage?(stage)
|
64
|
+
condition = stage.condition
|
65
|
+
# is_condition_opposite = stage.is_condition_opposite
|
66
|
+
|
67
|
+
result = prepare_condition_for(condition) # rubocop:disable Style/RedundantAssignment
|
68
|
+
|
69
|
+
# is_condition_opposite ? !result : result
|
70
|
+
result
|
71
|
+
end
|
72
|
+
|
73
|
+
def unnecessary_for_make?(make_method)
|
62
74
|
condition = make_method.condition
|
63
75
|
is_condition_opposite = make_method.is_condition_opposite
|
64
76
|
|
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: 1.6.
|
4
|
+
version: 1.6.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|