servactory 1.5.2 → 1.6.1

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -394
  3. data/config/locales/en.yml +5 -5
  4. data/lib/servactory/base.rb +4 -4
  5. data/lib/servactory/configuration/factory.rb +10 -6
  6. data/lib/servactory/configuration/setup.rb +10 -7
  7. data/lib/servactory/context/callable.rb +21 -22
  8. data/lib/servactory/context/workspace/inputs.rb +13 -0
  9. data/lib/servactory/context/workspace.rb +9 -7
  10. data/lib/servactory/errors/base.rb +2 -1
  11. data/lib/servactory/errors/collection.rb +25 -0
  12. data/lib/servactory/errors/failure.rb +11 -1
  13. data/lib/servactory/errors/input_error.rb +17 -0
  14. data/lib/servactory/errors/internal_error.rb +15 -0
  15. data/lib/servactory/errors/output_error.rb +15 -0
  16. data/lib/servactory/{input_arguments → inputs}/checks/base.rb +3 -3
  17. data/lib/servactory/{input_arguments → inputs}/checks/errors.rb +1 -1
  18. data/lib/servactory/{input_arguments → inputs}/checks/inclusion.rb +2 -2
  19. data/lib/servactory/{input_arguments → inputs}/checks/must.rb +3 -3
  20. data/lib/servactory/{input_arguments → inputs}/checks/required.rb +2 -2
  21. data/lib/servactory/{input_arguments → inputs}/checks/type.rb +3 -3
  22. data/lib/servactory/{input_arguments → inputs}/collection.rb +1 -1
  23. data/lib/servactory/{input_arguments → inputs}/define_input_conflict.rb +1 -1
  24. data/lib/servactory/{input_arguments → inputs}/define_input_method.rb +1 -1
  25. data/lib/servactory/inputs/dsl.rb +36 -0
  26. data/lib/servactory/{input_arguments/input_argument.rb → inputs/input.rb} +12 -12
  27. data/lib/servactory/{input_arguments → inputs}/option.rb +5 -3
  28. data/lib/servactory/{input_arguments → inputs}/options_collection.rb +1 -1
  29. data/lib/servactory/{input_arguments → inputs}/tools/check.rb +5 -5
  30. data/lib/servactory/{input_arguments → inputs}/tools/check_errors.rb +1 -1
  31. data/lib/servactory/{input_arguments → inputs}/tools/find_unnecessary.rb +6 -6
  32. data/lib/servactory/{input_arguments → inputs}/tools/prepare.rb +5 -5
  33. data/lib/servactory/inputs/tools/rules.rb +46 -0
  34. data/lib/servactory/{input_arguments → inputs}/workbench.rb +8 -8
  35. data/lib/servactory/internals/checks/base.rb +17 -0
  36. data/lib/servactory/{internal_arguments → internals}/checks/type.rb +8 -8
  37. data/lib/servactory/{output_arguments → internals}/collection.rb +1 -1
  38. data/lib/servactory/internals/dsl.rb +33 -0
  39. data/lib/servactory/{internal_arguments/internal_argument.rb → internals/internal.rb} +2 -2
  40. data/lib/servactory/internals/tools/prepare.rb +60 -0
  41. data/lib/servactory/{internal_arguments → internals}/workbench.rb +5 -5
  42. data/lib/servactory/{make_methods → methods}/collection.rb +1 -1
  43. data/lib/servactory/methods/dsl.rb +47 -0
  44. data/lib/servactory/{make_methods/make_method.rb → methods/method.rb} +2 -2
  45. data/lib/servactory/methods/shortcuts/collection.rb +17 -0
  46. data/lib/servactory/{make_methods → methods}/workbench.rb +6 -6
  47. data/lib/servactory/outputs/checks/base.rb +17 -0
  48. data/lib/servactory/{output_arguments → outputs}/checks/type.rb +8 -8
  49. data/lib/servactory/{internal_arguments → outputs}/collection.rb +1 -1
  50. data/lib/servactory/outputs/dsl.rb +33 -0
  51. data/lib/servactory/{output_arguments/output_argument.rb → outputs/output.rb} +2 -2
  52. data/lib/servactory/{output_arguments → outputs}/tools/conflicts.rb +7 -7
  53. data/lib/servactory/outputs/tools/prepare.rb +62 -0
  54. data/lib/servactory/outputs/workbench.rb +31 -0
  55. data/lib/servactory/result.rb +4 -4
  56. data/lib/servactory/utils.rb +2 -0
  57. data/lib/servactory/version.rb +2 -2
  58. metadata +60 -47
  59. data/lib/servactory/context/configuration.rb +0 -23
  60. data/lib/servactory/context/workspace/error.rb +0 -19
  61. data/lib/servactory/context/workspace/errors.rb +0 -33
  62. data/lib/servactory/errors/input_argument_error.rb +0 -7
  63. data/lib/servactory/errors/internal_argument_error.rb +0 -7
  64. data/lib/servactory/errors/output_argument_error.rb +0 -7
  65. data/lib/servactory/input_arguments/dsl.rb +0 -36
  66. data/lib/servactory/input_arguments/tools/rules.rb +0 -43
  67. data/lib/servactory/inputs.rb +0 -9
  68. data/lib/servactory/internal_arguments/checks/base.rb +0 -17
  69. data/lib/servactory/internal_arguments/dsl.rb +0 -33
  70. data/lib/servactory/internal_arguments/tools/prepare.rb +0 -60
  71. data/lib/servactory/make_methods/dsl.rb +0 -33
  72. data/lib/servactory/output_arguments/checks/base.rb +0 -17
  73. data/lib/servactory/output_arguments/dsl.rb +0 -33
  74. data/lib/servactory/output_arguments/tools/prepare.rb +0 -62
  75. data/lib/servactory/output_arguments/workbench.rb +0 -31
@@ -2,6 +2,16 @@
2
2
 
3
3
  module Servactory
4
4
  module Errors
5
- class Failure < Servactory::Errors::Base; end
5
+ class Failure < Base
6
+ attr_reader :message,
7
+ :meta
8
+
9
+ def initialize(message:, meta: nil)
10
+ @message = message
11
+ @meta = meta
12
+
13
+ super(message)
14
+ end
15
+ end
6
16
  end
7
17
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Errors
5
+ class InputError < Base
6
+ attr_reader :message,
7
+ :input_name
8
+
9
+ def initialize(message:, input_name: nil)
10
+ @message = message
11
+ @input_name = input_name&.to_sym
12
+
13
+ super(message)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Errors
5
+ class InternalError < Base
6
+ attr_reader :message
7
+
8
+ def initialize(message:)
9
+ @message = message
10
+
11
+ super(message)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Errors
5
+ class OutputError < Base
6
+ attr_reader :message
7
+
8
+ def initialize(message:)
9
+ @message = message
10
+
11
+ super(message)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Checks
6
6
  class Base
7
7
  protected
8
8
 
9
- def add_error(message, **arguments)
10
- message = message.call(**arguments) if message.is_a?(Proc)
9
+ def add_error(message, **attributes)
10
+ message = message.call(**attributes) if message.is_a?(Proc)
11
11
 
12
12
  errors << message
13
13
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Checks
6
6
  class Errors
7
7
  # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Checks
6
6
  class Inclusion < Base
7
7
  DEFAULT_MESSAGE = lambda do |service_class_name:, input:, value:|
8
8
  I18n.t(
9
- "servactory.input_arguments.checks.inclusion.default_error",
9
+ "servactory.inputs.checks.inclusion.default_error",
10
10
  service_class_name: service_class_name,
11
11
  input_name: input.name,
12
12
  input_inclusion: input.inclusion[:in],
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Checks
6
6
  class Must < Base
7
7
  DEFAULT_MESSAGE = lambda do |service_class_name:, input:, value:, code:|
8
8
  I18n.t(
9
- "servactory.input_arguments.checks.must.default_error",
9
+ "servactory.inputs.checks.must.default_error",
10
10
  service_class_name: service_class_name,
11
11
  input_name: input.name,
12
12
  value: value,
@@ -16,7 +16,7 @@ module Servactory
16
16
 
17
17
  SYNTAX_ERROR_MESSAGE = lambda do |service_class_name:, input:, value:, code:, exception_message:|
18
18
  I18n.t(
19
- "servactory.input_arguments.checks.must.syntax_error",
19
+ "servactory.inputs.checks.must.syntax_error",
20
20
  service_class_name: service_class_name,
21
21
  input_name: input.name,
22
22
  value: value,
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Checks
6
6
  class Required < Base
7
7
  DEFAULT_MESSAGE = lambda do |service_class_name:, input:, value:|
8
- i18n_key = "servactory.input_arguments.checks.required.default_error."
8
+ i18n_key = "servactory.inputs.checks.required.default_error."
9
9
  i18n_key += input.array? && value.present? ? "for_array" : "default"
10
10
 
11
11
  I18n.t(
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Checks
6
6
  class Type < Base
7
7
  DEFAULT_MESSAGE = lambda do |service_class_name:, input:, expected_type:, given_type:|
@@ -14,7 +14,7 @@ module Servactory
14
14
  array_message
15
15
  else
16
16
  I18n.t(
17
- "servactory.input_arguments.checks.type.default_error.for_array",
17
+ "servactory.inputs.checks.type.default_error.for_array",
18
18
  service_class_name: service_class_name,
19
19
  input_name: input.name,
20
20
  expected_type: expected_type,
@@ -23,7 +23,7 @@ module Servactory
23
23
  end
24
24
  else
25
25
  I18n.t(
26
- "servactory.input_arguments.checks.type.default_error.default",
26
+ "servactory.inputs.checks.type.default_error.default",
27
27
  service_class_name: service_class_name,
28
28
  input_name: input.name,
29
29
  expected_type: expected_type,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  class Collection
6
6
  # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
7
  extend Forwardable
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  class DefineInputConflict
6
6
  attr_reader :content
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  class DefineInputMethod
6
6
  attr_reader :name,
7
7
  :content
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Inputs
5
+ module DSL
6
+ def self.included(base)
7
+ base.extend(ClassMethods)
8
+ end
9
+
10
+ module ClassMethods
11
+ def inherited(child)
12
+ super
13
+
14
+ child.send(:collection_of_inputs).merge(collection_of_inputs)
15
+ end
16
+
17
+ private
18
+
19
+ def input(name, **options)
20
+ collection_of_inputs << Input.new(
21
+ name,
22
+ **options
23
+ )
24
+ end
25
+
26
+ def collection_of_inputs
27
+ @collection_of_inputs ||= Collection.new
28
+ end
29
+
30
+ def inputs_workbench
31
+ @inputs_workbench ||= Workbench.work_with(collection_of_inputs)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
5
- class InputArgument # rubocop:disable Metrics/ClassLength
4
+ module Inputs
5
+ class Input # rubocop:disable Metrics/ClassLength
6
6
  ARRAY_DEFAULT_VALUE = ->(is: false, message: nil) { { is: is, message: message } }
7
7
 
8
8
  attr_reader :name,
@@ -29,18 +29,18 @@ module Servactory
29
29
  # rubocop:enable Style/KeywordParametersOrder
30
30
 
31
31
  def add_basic_options_with(type:, options:)
32
- # Check Class: Servactory::InputArguments::Checks::Required
32
+ # Check Class: Servactory::Inputs::Checks::Required
33
33
  add_required_option_with(options)
34
34
 
35
- # Check Class: Servactory::InputArguments::Checks::Type
35
+ # Check Class: Servactory::Inputs::Checks::Type
36
36
  add_types_option_with(type)
37
37
  add_default_option_with(options)
38
38
  add_array_option_with(options)
39
39
 
40
- # Check Class: Servactory::InputArguments::Checks::Inclusion
40
+ # Check Class: Servactory::Inputs::Checks::Inclusion
41
41
  add_inclusion_option_with(options)
42
42
 
43
- # Check Class: Servactory::InputArguments::Checks::Must
43
+ # Check Class: Servactory::Inputs::Checks::Must
44
44
  add_must_option_with(options)
45
45
 
46
46
  # Check Class: nil
@@ -51,7 +51,7 @@ module Servactory
51
51
  collection_of_options << Option.new(
52
52
  name: :required,
53
53
  input: self,
54
- check_class: Servactory::InputArguments::Checks::Required,
54
+ check_class: Servactory::Inputs::Checks::Required,
55
55
  define_input_methods: [
56
56
  DefineInputMethod.new(
57
57
  name: :required?,
@@ -76,7 +76,7 @@ module Servactory
76
76
  collection_of_options << Option.new(
77
77
  name: :types,
78
78
  input: self,
79
- check_class: Servactory::InputArguments::Checks::Type,
79
+ check_class: Servactory::Inputs::Checks::Type,
80
80
  original_value: Array(type),
81
81
  need_for_checks: true,
82
82
  value_fallback: nil,
@@ -88,7 +88,7 @@ module Servactory
88
88
  collection_of_options << Option.new(
89
89
  name: :default,
90
90
  input: self,
91
- check_class: Servactory::InputArguments::Checks::Type,
91
+ check_class: Servactory::Inputs::Checks::Type,
92
92
  define_input_methods: [
93
93
  DefineInputMethod.new(
94
94
  name: :default_value_present?,
@@ -106,7 +106,7 @@ module Servactory
106
106
  collection_of_options << Option.new(
107
107
  name: :array,
108
108
  input: self,
109
- check_class: Servactory::InputArguments::Checks::Type,
109
+ check_class: Servactory::Inputs::Checks::Type,
110
110
  define_input_methods: [
111
111
  DefineInputMethod.new(
112
112
  name: :array?,
@@ -128,7 +128,7 @@ module Servactory
128
128
  collection_of_options << Option.new(
129
129
  name: :inclusion,
130
130
  input: self,
131
- check_class: Servactory::InputArguments::Checks::Inclusion,
131
+ check_class: Servactory::Inputs::Checks::Inclusion,
132
132
  define_input_methods: [
133
133
  DefineInputMethod.new(
134
134
  name: :inclusion_present?,
@@ -146,7 +146,7 @@ module Servactory
146
146
  collection_of_options << Option.new(
147
147
  name: :must,
148
148
  input: self,
149
- check_class: Servactory::InputArguments::Checks::Must,
149
+ check_class: Servactory::Inputs::Checks::Must,
150
150
  define_input_methods: [
151
151
  DefineInputMethod.new(
152
152
  name: :must_present?,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  class Option
6
6
  DEFAULT_VALUE = ->(key:, value:, message: nil) { { key => value, message: message } }
7
7
 
@@ -66,10 +66,12 @@ module Servactory
66
66
 
67
67
  def prepare_advanced_for(value:, value_fallback:)
68
68
  if value.is_a?(Hash)
69
+ message = value.fetch(:message, nil)
70
+
69
71
  DEFAULT_VALUE.call(
70
72
  key: value_key,
71
- value: value.fetch(value_key, value_fallback),
72
- message: value.fetch(:message, nil)
73
+ value: value.fetch(value_key, message.present? ? true : value_fallback),
74
+ message: message
73
75
  )
74
76
  else
75
77
  DEFAULT_VALUE.call(key: value_key, value: value)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  class OptionsCollection
6
6
  # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
7
  extend Forwardable
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Tools
6
6
  class Check
7
7
  def self.check!(...)
8
8
  new(...).check!
9
9
  end
10
10
 
11
- def initialize(context, incoming_arguments, collection_of_input_arguments)
11
+ def initialize(context, incoming_arguments, collection_of_inputs)
12
12
  @context = context
13
13
  @incoming_arguments = incoming_arguments
14
- @collection_of_input_arguments = collection_of_input_arguments
14
+ @collection_of_inputs = collection_of_inputs
15
15
  end
16
16
 
17
17
  def check!
18
- @collection_of_input_arguments.each do |input|
18
+ @collection_of_inputs.each do |input|
19
19
  process_input(input)
20
20
  end
21
21
 
@@ -68,7 +68,7 @@ module Servactory
68
68
  def raise_errors
69
69
  return if (tmp_errors = errors.not_blank).empty?
70
70
 
71
- raise Servactory.configuration.input_argument_error_class, tmp_errors.first
71
+ raise Servactory.configuration.input_error_class.new(message: tmp_errors.first)
72
72
  end
73
73
  end
74
74
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Tools
6
6
  class CheckErrors
7
7
  # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
@@ -1,35 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Tools
6
6
  class FindUnnecessary
7
7
  def self.check!(...)
8
8
  new(...).check!
9
9
  end
10
10
 
11
- def initialize(context, incoming_arguments, collection_of_input_arguments)
11
+ def initialize(context, incoming_arguments, collection_of_inputs)
12
12
  @context = context
13
13
  @incoming_arguments = incoming_arguments
14
- @collection_of_input_arguments = collection_of_input_arguments
14
+ @collection_of_inputs = collection_of_inputs
15
15
  end
16
16
 
17
17
  def check!
18
18
  return if unnecessary_attributes.empty?
19
19
 
20
20
  message_text = I18n.t(
21
- "servactory.input_arguments.tools.find_unnecessary.error",
21
+ "servactory.inputs.tools.find_unnecessary.error",
22
22
  service_class_name: @context.class.name,
23
23
  unnecessary_attributes: unnecessary_attributes.join(", ")
24
24
  )
25
25
 
26
- raise Servactory.configuration.input_argument_error_class, message_text
26
+ raise Servactory.configuration.input_error_class.new(message: message_text)
27
27
  end
28
28
 
29
29
  private
30
30
 
31
31
  def unnecessary_attributes
32
- @unnecessary_attributes ||= @incoming_arguments.keys - @collection_of_input_arguments.names
32
+ @unnecessary_attributes ||= @incoming_arguments.keys - @collection_of_inputs.names
33
33
  end
34
34
  end
35
35
  end
@@ -1,24 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  module Tools
6
6
  class Prepare
7
7
  def self.prepare(...)
8
8
  new(...).prepare
9
9
  end
10
10
 
11
- def initialize(context, incoming_arguments, collection_of_input_arguments)
11
+ def initialize(context, incoming_arguments, collection_of_inputs)
12
12
  @context = context
13
13
  @incoming_arguments = incoming_arguments
14
- @collection_of_input_arguments = collection_of_input_arguments
14
+ @collection_of_inputs = collection_of_inputs
15
15
  end
16
16
 
17
17
  def prepare
18
18
  @inputs_variables = {}
19
19
  @internal_variables = {}
20
20
 
21
- @collection_of_input_arguments.each do |input|
21
+ @collection_of_inputs.each do |input|
22
22
  process_input(input)
23
23
  end
24
24
 
@@ -39,7 +39,7 @@ module Servactory
39
39
  end
40
40
 
41
41
  def create_instance_variables
42
- inputs_class = Servactory::Inputs.dup
42
+ inputs_class = Servactory::Context::Workspace::Inputs.dup
43
43
  inputs_class.class_eval(class_inputs_template) if class_inputs_template.present?
44
44
 
45
45
  @context.assign_inputs(inputs_class.new(**@inputs_variables))
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Inputs
5
+ module Tools
6
+ class Rules
7
+ def self.check!(...)
8
+ new(...).check!
9
+ end
10
+
11
+ def initialize(context, collection_of_inputs)
12
+ @context = context
13
+ @collection_of_inputs = collection_of_inputs
14
+ end
15
+
16
+ def check!
17
+ @collection_of_inputs.each do |input|
18
+ check_for!(input)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def check_for!(input)
25
+ return unless input.with_conflicts?
26
+
27
+ raise_error_for(input)
28
+ end
29
+
30
+ def raise_error_for(input)
31
+ message_text = I18n.t(
32
+ "servactory.inputs.tools.rules.error",
33
+ service_class_name: @context.class.name,
34
+ input_name: input.name,
35
+ conflict_code: input.conflict_code
36
+ )
37
+
38
+ raise Servactory.configuration.input_error_class.new(
39
+ message: message_text,
40
+ input_name: input.name
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InputArguments
4
+ module Inputs
5
5
  class Workbench
6
6
  def self.work_with(...)
7
7
  new(...)
8
8
  end
9
9
 
10
- def initialize(collection_of_input_arguments)
11
- @collection_of_input_arguments = collection_of_input_arguments
10
+ def initialize(collection_of_inputs)
11
+ @collection_of_inputs = collection_of_inputs
12
12
  end
13
13
 
14
14
  def assign(context:, arguments:)
@@ -17,25 +17,25 @@ module Servactory
17
17
  end
18
18
 
19
19
  def find_unnecessary!
20
- Tools::FindUnnecessary.check!(context, @incoming_arguments, collection_of_input_arguments)
20
+ Tools::FindUnnecessary.check!(context, @incoming_arguments, collection_of_inputs)
21
21
  end
22
22
 
23
23
  def check_rules!
24
- Tools::Rules.check!(context, collection_of_input_arguments)
24
+ Tools::Rules.check!(context, collection_of_inputs)
25
25
  end
26
26
 
27
27
  def prepare
28
- Tools::Prepare.prepare(context, @incoming_arguments, collection_of_input_arguments)
28
+ Tools::Prepare.prepare(context, @incoming_arguments, collection_of_inputs)
29
29
  end
30
30
 
31
31
  def check!
32
- Tools::Check.check!(context, @incoming_arguments, collection_of_input_arguments)
32
+ Tools::Check.check!(context, @incoming_arguments, collection_of_inputs)
33
33
  end
34
34
 
35
35
  private
36
36
 
37
37
  attr_reader :context,
38
- :collection_of_input_arguments
38
+ :collection_of_inputs
39
39
  end
40
40
  end
41
41
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Internals
5
+ module Checks
6
+ class Base
7
+ protected
8
+
9
+ def raise_error_with(message, **attributes)
10
+ message = message.call(**attributes) if message.is_a?(Proc)
11
+
12
+ raise Servactory.configuration.internal_error_class.new(message: message)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module InternalArguments
4
+ module Internals
5
5
  module Checks
6
6
  class Type < Base
7
- DEFAULT_MESSAGE = lambda do |service_class_name:, internal_argument:, expected_type:, given_type:|
7
+ DEFAULT_MESSAGE = lambda do |service_class_name:, internal:, expected_type:, given_type:|
8
8
  I18n.t(
9
- "servactory.internal_arguments.checks.type.default_error",
9
+ "servactory.internals.checks.type.default_error",
10
10
  service_class_name: service_class_name,
11
- internal_argument_name: internal_argument.name,
11
+ internal_name: internal.name,
12
12
  expected_type: expected_type,
13
13
  given_type: given_type
14
14
  )
@@ -22,11 +22,11 @@ module Servactory
22
22
 
23
23
  ##########################################################################
24
24
 
25
- def initialize(context:, internal_argument:, value:)
25
+ def initialize(context:, internal:, value:)
26
26
  super()
27
27
 
28
28
  @context = context
29
- @internal_argument = internal_argument
29
+ @internal = internal
30
30
  @value = value
31
31
  end
32
32
 
@@ -36,7 +36,7 @@ module Servactory
36
36
  raise_error_with(
37
37
  DEFAULT_MESSAGE,
38
38
  service_class_name: @context.class.name,
39
- internal_argument: @internal_argument,
39
+ internal: @internal,
40
40
  expected_type: prepared_types.join(", "),
41
41
  given_type: @value.class.name
42
42
  )
@@ -46,7 +46,7 @@ module Servactory
46
46
 
47
47
  def prepared_types
48
48
  @prepared_types ||=
49
- Array(@internal_argument.types).map do |type|
49
+ Array(@internal.types).map do |type|
50
50
  if type.is_a?(String)
51
51
  Object.const_get(type)
52
52
  else
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module OutputArguments
4
+ module Internals
5
5
  class Collection
6
6
  # NOTE: http://words.steveklabnik.com/beware-subclassing-ruby-core-classes
7
7
  extend Forwardable