servactory 1.5.0 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 417ec054ab2d314d3a54167a81ee92408cc3f631fea88220d85d06838dcb86db
4
- data.tar.gz: 4e49086ca53660fd8e7e7cddce9734092703278f6da7f3880b43922ae053fe49
3
+ metadata.gz: 2f9511d2fb9a463c46f04ba4e6f005b14f9048039524a1aed476ee1a4fa997ef
4
+ data.tar.gz: f5e03fa8943d3a5fd4735ec3817528202ce3b2e06106d81f0ad08fde2e4e4baf
5
5
  SHA512:
6
- metadata.gz: b511278027c0384d1643b46b3b88a48e17f1f2b5685824f06190f98c07f5e4398a5494b9da8c2c75250ed14c1f3b3123b2c917bb00fa0a9159b5ccecc1fc2117
7
- data.tar.gz: '0865a04061268ae4e582a499728b4b881d41d398cf322c9a91f10d24f14588904b1c65dca2f81750bd5bd912ac04384344216d73aed6f5699499c50531a884f6'
6
+ metadata.gz: 406a99f8386dc97033fd28231e8b11438aa8827878ee332b11efa43747b92f7fcc993b547413733651a93bc0d1f59f6799f4b7e70778038f685d91206ff35be9
7
+ data.tar.gz: 2895de4a4fc256dcec75cddaddc0ff92b70e9cf42de13309acde95447b0466d4afa8103d52b6ec66e219109065f7f9ffea022c7c41789e88383f32cf08a5e8bb
@@ -58,8 +58,7 @@ module Servactory
58
58
  def assign_data_with(arguments)
59
59
  input_arguments_workbench.assign(
60
60
  context: context_store.context,
61
- arguments: arguments,
62
- collection_of_input_options: collection_of_input_options
61
+ arguments: arguments
63
62
  )
64
63
 
65
64
  internal_arguments_workbench.assign(context: context_store.context)
@@ -37,10 +37,13 @@ module Servactory
37
37
  end
38
38
 
39
39
  def check
40
- return if @input.inclusion[:in].include?(@value)
40
+ inclusion_in, message = @input.inclusion.values_at(:in, :message)
41
+
42
+ return if inclusion_in.nil?
43
+ return if inclusion_in.include?(@value)
41
44
 
42
45
  add_error(
43
- DEFAULT_MESSAGE,
46
+ message.presence || DEFAULT_MESSAGE,
44
47
  service_class_name: @context.class.name,
45
48
  input: @input,
46
49
  value: @value
@@ -19,7 +19,6 @@ module Servactory
19
19
  def input(name, **options)
20
20
  collection_of_input_arguments << InputArgument.new(
21
21
  name,
22
- collection_of_options: collection_of_input_options,
23
22
  **options
24
23
  )
25
24
  end
@@ -28,10 +27,6 @@ module Servactory
28
27
  @collection_of_input_arguments ||= Collection.new
29
28
  end
30
29
 
31
- def collection_of_input_options
32
- @collection_of_input_options ||= OptionsCollection.new
33
- end
34
-
35
30
  def input_arguments_workbench
36
31
  @input_arguments_workbench ||= Workbench.work_with(collection_of_input_arguments)
37
32
  end
@@ -6,24 +6,21 @@ module Servactory
6
6
  ARRAY_DEFAULT_VALUE = ->(is: false, message: nil) { { is: is, message: message } }
7
7
 
8
8
  attr_reader :name,
9
- :internal_name,
10
- :collection_of_options
9
+ :internal_name
11
10
 
12
11
  # rubocop:disable Style/KeywordParametersOrder
13
12
  def initialize(
14
13
  name,
15
14
  as: nil,
16
- collection_of_options:,
17
15
  type:,
18
16
  **options
19
17
  )
20
18
  @name = name
21
19
  @internal_name = as.present? ? as : name
22
- @collection_of_options = collection_of_options
23
20
 
24
21
  add_basic_options_with(type: type, options: options)
25
22
 
26
- @collection_of_options.each do |option|
23
+ collection_of_options.each do |option|
27
24
  self.class.attr_reader(:"#{option.name}")
28
25
 
29
26
  instance_variable_set(:"@#{option.name}", option.value)
@@ -182,6 +179,10 @@ module Servactory
182
179
  )
183
180
  end
184
181
 
182
+ def collection_of_options
183
+ @collection_of_options ||= OptionsCollection.new
184
+ end
185
+
185
186
  def options_for_checks
186
187
  collection_of_options.options_for_checks
187
188
  end
@@ -8,11 +8,10 @@ module Servactory
8
8
  new(...).check!
9
9
  end
10
10
 
11
- def initialize(context, incoming_arguments, collection_of_input_arguments, collection_of_input_options)
11
+ def initialize(context, incoming_arguments, collection_of_input_arguments)
12
12
  @context = context
13
13
  @incoming_arguments = incoming_arguments
14
14
  @collection_of_input_arguments = collection_of_input_arguments
15
- @collection_of_input_options = collection_of_input_options
16
15
  end
17
16
 
18
17
  def check!
@@ -32,7 +31,7 @@ module Servactory
32
31
  end
33
32
 
34
33
  def process_option(check_key, check_options, input:)
35
- check_classes.each do |check_class|
34
+ check_classes_from(input).each do |check_class|
36
35
  errors_from_checks = process_check_class(
37
36
  check_class,
38
37
  input: input,
@@ -56,8 +55,8 @@ module Servactory
56
55
 
57
56
  ########################################################################
58
57
 
59
- def check_classes
60
- @collection_of_input_options.check_classes
58
+ def check_classes_from(input)
59
+ input.collection_of_options.check_classes
61
60
  end
62
61
 
63
62
  ########################################################################
@@ -11,10 +11,9 @@ module Servactory
11
11
  @collection_of_input_arguments = collection_of_input_arguments
12
12
  end
13
13
 
14
- def assign(context:, arguments:, collection_of_input_options:)
14
+ def assign(context:, arguments:)
15
15
  @context = context
16
16
  @incoming_arguments = arguments
17
- @collection_of_input_options = collection_of_input_options
18
17
  end
19
18
 
20
19
  def find_unnecessary!
@@ -30,14 +29,13 @@ module Servactory
30
29
  end
31
30
 
32
31
  def check!
33
- Tools::Check.check!(context, @incoming_arguments, collection_of_input_arguments, collection_of_input_options)
32
+ Tools::Check.check!(context, @incoming_arguments, collection_of_input_arguments)
34
33
  end
35
34
 
36
35
  private
37
36
 
38
37
  attr_reader :context,
39
- :collection_of_input_arguments,
40
- :collection_of_input_options
38
+ :collection_of_input_arguments
41
39
  end
42
40
  end
43
41
  end
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 5
7
- PATCH = 0
7
+ PATCH = 2
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
10
10
  end
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.5.0
4
+ version: 1.5.2
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-05-20 00:00:00.000000000 Z
11
+ date: 2023-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport