servactory 1.9.2 → 1.9.3

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: e1976d91976a495a0b930a03ad29e12240bddf6cba102c118c0ec12f871a023d
4
- data.tar.gz: 1b6ec8440f14820138c8fd380de3b4a13cf3eda761493a082cf2c56ed3e8c133
3
+ metadata.gz: 026f0a67d02ac1eb1053768585e80684a7bbaa4acbf3b381213d145cfbefe4ae
4
+ data.tar.gz: 362040a5cfe9b33d28b1a83bedb21efa7d2fa701272c7b30f739c6a8f025af42
5
5
  SHA512:
6
- metadata.gz: 06d9b0f22847032a47c7ea4c12a495bf4e4b451e5041ef91ca3be13e05597a98fa4857ffbd3c2d00cdbe7b14c4c47733cbccf4573e3be154e3051fdb1cc08259
7
- data.tar.gz: 3a9244a611b5c01f3fd4aff99a1784b399cff79a0a9c3207afc59114cca26c4a780dd80b7b1849f9f27a313780187208e8784bd51cff74f9d131f613c52193aa
6
+ metadata.gz: 449c7dd9083b99629621e0cd04bcbd07e3b01b3081fc64cc36042922d3c8fa603a8f2efb6d14fe53b8b233ec9437bf82d994831e5cbc002b4ccad5829775ea1d
7
+ data.tar.gz: 932159f75fb820fd9adad6f0f2bb6bae88e2ac74d87d9e2293caab4c5a5cb691a6d161bfe4ac4e3f89527b2f106ff52d36119cbb765ccbed2767cb70ab1b8b2d
@@ -1,6 +1,9 @@
1
1
  en:
2
2
  servactory:
3
3
  inputs:
4
+ undefined:
5
+ getter: "[%{service_class_name}] Undefined input attribute `%{input_name}`"
6
+ setter: "[%{service_class_name}] Undefined input attribute `%{input_name}`"
4
7
  checks:
5
8
  inclusion:
6
9
  default_error: "[%{service_class_name}] Wrong value in `%{input_name}`, must be one of `%{input_inclusion}`"
@@ -21,10 +24,16 @@ en:
21
24
  rules:
22
25
  error: "[%{service_class_name}] Conflict in `%{input_name}` input options: `%{conflict_code}`"
23
26
  internals:
27
+ undefined:
28
+ getter: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
29
+ setter: "[%{service_class_name}] Undefined internal attribute `%{internal_name}`"
24
30
  checks:
25
31
  type:
26
32
  default_error: "[%{service_class_name}] Wrong type of internal attribute `%{internal_name}`, expected `%{expected_type}`, got `%{given_type}`"
27
33
  outputs:
34
+ undefined:
35
+ getter: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
36
+ setter: "[%{service_class_name}] Undefined output attribute `%{output_name}`"
28
37
  checks:
29
38
  type:
30
39
  default_error: "[%{service_class_name}] Wrong type of output attribute `%{output_name}`, expected `%{expected_type}`, got `%{given_type}`"
@@ -1,6 +1,9 @@
1
1
  ru:
2
2
  servactory:
3
3
  inputs:
4
+ undefined:
5
+ getter: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
6
+ setter: "[%{service_class_name}] Неизвестный входящий атрибут `%{input_name}`"
4
7
  checks:
5
8
  inclusion:
6
9
  default_error: "[%{service_class_name}] Неверное значение в `%{input_name}`, должно быть одним из `%{input_inclusion}`"
@@ -21,10 +24,16 @@ ru:
21
24
  rules:
22
25
  error: "[%{service_class_name}] Конфликт в опциях инпута `%{input_name}`: `%{conflict_code}`"
23
26
  internals:
27
+ undefined:
28
+ getter: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
29
+ setter: "[%{service_class_name}] Неизвестный внутренний атрибут `%{internal_name}`"
24
30
  checks:
25
31
  type:
26
32
  default_error: "[%{service_class_name}] Неверный тип внутреннего атрибута `%{internal_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
27
33
  outputs:
34
+ undefined:
35
+ getter: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
36
+ setter: "[%{service_class_name}] Неизвестный выходящий атрибут `%{output_name}`"
28
37
  checks:
29
38
  type:
30
39
  default_error: "[%{service_class_name}] Неверный тип выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
@@ -11,10 +11,12 @@ module Servactory
11
11
  end
12
12
 
13
13
  def method_missing(name, *args, &block)
14
+ prepared_name = name.to_s.delete("=").to_sym
15
+
14
16
  if name.to_s.end_with?("=")
15
- super
17
+ raise_error_for(:setter, prepared_name)
16
18
  else
17
- getter_with(name: name) { super }
19
+ getter_with(name: name) { raise_error_for(:getter, name) }
18
20
  end
19
21
  end
20
22
 
@@ -42,6 +44,16 @@ module Servactory
42
44
  input_value
43
45
  end
44
46
  end
47
+
48
+ def raise_error_for(type, name)
49
+ message_text = I18n.t(
50
+ "servactory.inputs.undefined.#{type}",
51
+ service_class_name: @context.class.name,
52
+ input_name: name
53
+ )
54
+
55
+ raise @context.class.config.input_error_class.new(message: message_text, input_name: name)
56
+ end
45
57
  end
46
58
  end
47
59
  end
@@ -10,10 +10,12 @@ module Servactory
10
10
  end
11
11
 
12
12
  def method_missing(name, *args, &block)
13
+ prepared_name = name.to_s.delete("=").to_sym
14
+
13
15
  if name.to_s.end_with?("=")
14
- setter_with(name: name, value: args.pop) { super }
16
+ setter_with(prepared_name: prepared_name, value: args.pop) { raise_error_for(:setter, prepared_name) }
15
17
  else
16
- getter_with(name: name) { super }
18
+ getter_with(name: name) { raise_error_for(:getter, prepared_name) }
17
19
  end
18
20
  end
19
21
 
@@ -23,9 +25,7 @@ module Servactory
23
25
 
24
26
  private
25
27
 
26
- def setter_with(name:, value:, &block) # rubocop:disable Lint/UnusedMethodArgument
27
- prepared_name = name.to_s.delete("=").to_sym
28
-
28
+ def setter_with(prepared_name:, value:, &block) # rubocop:disable Lint/UnusedMethodArgument
29
29
  return yield unless @collection_of_internals.names.include?(prepared_name)
30
30
 
31
31
  internal = @collection_of_internals.find_by(name: prepared_name) # ::Servactory::Internals::Internal
@@ -55,6 +55,16 @@ module Servactory
55
55
  internal_value
56
56
  end
57
57
  end
58
+
59
+ def raise_error_for(type, name)
60
+ message_text = I18n.t(
61
+ "servactory.internals.undefined.#{type}",
62
+ service_class_name: @context.class.name,
63
+ internal_name: name
64
+ )
65
+
66
+ raise @context.class.config.input_error_class.new(message: message_text)
67
+ end
58
68
  end
59
69
  end
60
70
  end
@@ -10,10 +10,12 @@ module Servactory
10
10
  end
11
11
 
12
12
  def method_missing(name, *args, &block)
13
+ prepared_name = name.to_s.delete("=").to_sym
14
+
13
15
  if name.to_s.end_with?("=")
14
- setter_with(name: name, value: args.pop) { super }
16
+ setter_with(prepared_name: prepared_name, value: args.pop) { raise_error_for(:setter, prepared_name) }
15
17
  else
16
- getter_with(name: name) { super }
18
+ getter_with(name: name) { raise_error_for(:getter, prepared_name) }
17
19
  end
18
20
  end
19
21
 
@@ -23,9 +25,7 @@ module Servactory
23
25
 
24
26
  private
25
27
 
26
- def setter_with(name:, value:, &block) # rubocop:disable Lint/UnusedMethodArgument
27
- prepared_name = name.to_s.delete("=").to_sym
28
-
28
+ def setter_with(prepared_name:, value:, &block) # rubocop:disable Lint/UnusedMethodArgument
29
29
  return yield unless @collection_of_outputs.names.include?(prepared_name)
30
30
 
31
31
  output = @collection_of_outputs.find_by(name: prepared_name) # ::Servactory::Outputs::Output
@@ -55,6 +55,16 @@ module Servactory
55
55
  output_value
56
56
  end
57
57
  end
58
+
59
+ def raise_error_for(type, name)
60
+ message_text = I18n.t(
61
+ "servactory.outputs.undefined.#{type}",
62
+ service_class_name: @context.class.name,
63
+ output_name: name
64
+ )
65
+
66
+ raise @context.class.config.output_error_class.new(message: message_text)
67
+ end
58
68
  end
59
69
  end
60
70
  end
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 9
7
- PATCH = 2
7
+ PATCH = 3
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.9.2
4
+ version: 1.9.3
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-07-24 00:00:00.000000000 Z
11
+ date: 2023-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport