servactory 1.9.1 → 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: 7e2700452d86edebc82fa3ee39440d45e145a60ce29100beb2e60e7a8fc8421e
4
- data.tar.gz: 12247104874465f4feb387201f52afb45ee941fce8cb18f9a303e08af117a3a7
3
+ metadata.gz: 026f0a67d02ac1eb1053768585e80684a7bbaa4acbf3b381213d145cfbefe4ae
4
+ data.tar.gz: 362040a5cfe9b33d28b1a83bedb21efa7d2fa701272c7b30f739c6a8f025af42
5
5
  SHA512:
6
- metadata.gz: 3f2a24c468da16bcc97e1e2cbbb86adf99c9e1a37b352e7e5e99e574a15333f8ca1cbf22b675fbc4387e4dfd2c6e52dc3e07bd3365569957385d4889195f02cb
7
- data.tar.gz: e3d2122b3438fb9c5fbc637535a8450771879cde90291978bb111a0e94a4c4f9440269f2c6b253fb7d2360581166a793a12498f77544d627287eae0d56927dd5
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}`"
@@ -8,7 +8,7 @@ module Servactory
8
8
 
9
9
  context.send(
10
10
  :_call!,
11
- incoming_arguments: arguments,
11
+ incoming_arguments: arguments.symbolize_keys,
12
12
  collection_of_inputs: collection_of_inputs,
13
13
  collection_of_internals: collection_of_internals,
14
14
  collection_of_outputs: collection_of_outputs,
@@ -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
@@ -10,7 +10,7 @@ module Servactory
10
10
 
11
11
  def initialize(context, incoming_arguments, collection_of_inputs)
12
12
  @context = context
13
- @incoming_arguments = incoming_arguments.symbolize_keys
13
+ @incoming_arguments = incoming_arguments
14
14
  @collection_of_inputs = collection_of_inputs
15
15
  end
16
16
 
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 9
7
- PATCH = 1
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.1
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