servactory 2.15.1 → 2.16.0.rc1

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: ce9429e1b0d9bddfab017bae08915f91a41cf81826d54becffa3021e1fdcdb58
4
- data.tar.gz: a9d1ad2b9cd25dfd805df46df18cf4ef73d6feda77d16b0b208100b04984af29
3
+ metadata.gz: bc13e8261f2784169fde009e5f3fd2527e963e55cbda931d728c46319b395187
4
+ data.tar.gz: 9b4f88c9ba2695f0fa8c8084866bb27a1bcf99702890985e080d08a750d6e1c1
5
5
  SHA512:
6
- metadata.gz: 2a7a1d4a5356333cbec5eb3d25c11c9716cd4c56e9b15c320c572f49a58268da2ff4735706cd163c49d7d351e44daf02201fde43a0035dea9a7c8e96a6d28b74
7
- data.tar.gz: 81f5b4831820c6b944561409f2729875c021d554c880cac952a311214bf4fb05417c24e26a73f99b2104c80facc8b270b58228d3995cd753479ad3a9d3664648
6
+ metadata.gz: ab74975be82b4e3231a1ed12d92d12853755afe051e7e0f7144ae34efbc909c124e70091a333fba41c657c2f5344abd7cc649c5f9def2d37e7363b41ab39d794
7
+ data.tar.gz: b46024d472db88be0c99e9eb15c912089b4ebace519e39e5e840ba84272f7d61572fcf851c47b106e4acd44037798d9a7fd40547093521a87a180f6c3bac677a
@@ -44,11 +44,7 @@ module Servactory
44
44
  input_name:
45
45
  )
46
46
 
47
- raise @context.class.config.input_exception_class.new(
48
- context: @context,
49
- message: message_text,
50
- input_name:
51
- )
47
+ @context.fail_input!(input_name, message: message_text)
52
48
  end
53
49
  end
54
50
  end
@@ -68,11 +68,7 @@ module Servactory
68
68
  input_name: name
69
69
  )
70
70
 
71
- raise @context.class.config.input_exception_class.new(
72
- context: @context,
73
- message: message_text,
74
- input_name: name
75
- )
71
+ @context.fail_input!(name, message: message_text)
76
72
  end
77
73
  end
78
74
  end
@@ -80,10 +80,7 @@ module Servactory
80
80
  internal_name: name
81
81
  )
82
82
 
83
- raise @context.class.config.internal_exception_class.new(
84
- context: @context,
85
- message: message_text
86
- )
83
+ @context.fail_internal!(name, message: message_text)
87
84
  end
88
85
  end
89
86
  end
@@ -74,10 +74,7 @@ module Servactory
74
74
  output_name: name
75
75
  )
76
76
 
77
- raise @context.class.config.output_exception_class.new(
78
- context: @context,
79
- message: message_text
80
- )
77
+ @context.fail_output!(name, message: message_text)
81
78
  end
82
79
  end
83
80
  end
@@ -18,6 +18,10 @@ module Servactory
18
18
 
19
19
  Result.new(builder)
20
20
  end
21
+
22
+ def servactory?
23
+ true
24
+ end
21
25
  end
22
26
  end
23
27
  end
@@ -34,11 +34,7 @@ module Servactory
34
34
  conflict_code: input.conflict_code
35
35
  )
36
36
 
37
- raise @context.class.config.input_exception_class.new(
38
- context: @context,
39
- message: message_text,
40
- input_name: input.name
41
- )
37
+ @context.fail_input!(input.name, message: message_text)
42
38
  end
43
39
  end
44
40
  end
@@ -21,10 +21,7 @@ module Servactory
21
21
  unnecessary_attributes: unnecessary_attributes.join(", ")
22
22
  )
23
23
 
24
- raise @context.class.config.input_exception_class.new(
25
- context: @context,
26
- message: message_text
27
- )
24
+ @context.fail_input!(nil, message: message_text)
28
25
  end
29
26
 
30
27
  private
@@ -29,18 +29,21 @@ module Servactory
29
29
  end
30
30
  end
31
31
 
32
- def process_option(check_key, check_options, input:)
33
- validation_classes_from(input).each do |validation_class|
32
+ def process_option(check_key, check_options, input:) # rubocop:disable Metrics/MethodLength
33
+ validation_classes = validation_classes_from(input)
34
+ return if validation_classes.empty?
35
+
36
+ validation_classes.each do |validation_class|
34
37
  errors_from_checks = process_validation_class(
35
38
  validation_class:,
36
39
  input:,
37
40
  check_key:,
38
41
  check_options:
39
- ).to_a
42
+ )
40
43
 
41
- next if errors_from_checks.empty?
44
+ next if errors_from_checks.nil? || errors_from_checks.empty?
42
45
 
43
- errors.merge(errors_from_checks)
46
+ errors.merge(errors_from_checks.to_a)
44
47
  end
45
48
  end
46
49
 
@@ -62,7 +65,7 @@ module Servactory
62
65
  ########################################################################
63
66
 
64
67
  def validation_classes_from(input)
65
- input.collection_of_options.validation_classes
68
+ @validation_classes_cache ||= input.collection_of_options.validation_classes # rubocop:disable Naming/MemoizedInstanceVariableName
66
69
  end
67
70
 
68
71
  ########################################################################
@@ -74,10 +77,7 @@ module Servactory
74
77
  def raise_errors
75
78
  return if (tmp_errors = errors.not_blank).empty?
76
79
 
77
- raise @context.class.config.input_exception_class.new(
78
- context: @context,
79
- message: tmp_errors.first
80
- )
80
+ @context.fail_input!(nil, message: tmp_errors.first)
81
81
  end
82
82
  end
83
83
  end
@@ -17,7 +17,8 @@ module Servactory
17
17
  end
18
18
 
19
19
  def validation_classes
20
- filter { |option| option.validation_class.present? }
20
+ @validation_classes ||=
21
+ filter { |option| option.validation_class.present? }
21
22
  .map(&:validation_class)
22
23
  .uniq
23
24
  end
@@ -30,6 +30,8 @@ module Servactory
30
30
  end
31
31
 
32
32
  def process_option(check_key, check_options)
33
+ return if validation_classes.empty?
34
+
33
35
  validation_classes.each do |validation_class|
34
36
  errors_from_checks = process_validation_class(
35
37
  validation_class:,
@@ -37,6 +39,8 @@ module Servactory
37
39
  check_options:
38
40
  )
39
41
 
42
+ next if errors_from_checks.nil? || errors_from_checks.empty?
43
+
40
44
  errors.merge(errors_from_checks.to_a)
41
45
  end
42
46
  end
@@ -6,7 +6,7 @@ module Servactory
6
6
  module Validations
7
7
  class Errors
8
8
  extend Forwardable
9
- def_delegators :@collection, :<<, :to_a
9
+ def_delegators :@collection, :<<, :to_a, :empty?
10
10
 
11
11
  def initialize(*)
12
12
  @collection = Set.new
@@ -3,9 +3,9 @@
3
3
  module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 15
7
- PATCH = 1
8
- PRE = nil
6
+ MINOR = 16
7
+ PATCH = 0
8
+ PRE = "rc1"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.1
4
+ version: 2.16.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov