Class: Superstructure::ArgumentErrorBuilder
- Inherits:
-
Object
- Object
- Superstructure::ArgumentErrorBuilder
- Defined in:
- lib/superstructure/argument_error_builder.rb
Instance Method Summary collapse
- #add_error(type, key) ⇒ Object
- #add_errors(type, key) ⇒ Object
- #build ⇒ Object
- #error? ⇒ Boolean
-
#initialize ⇒ ArgumentErrorBuilder
constructor
A new instance of ArgumentErrorBuilder.
Constructor Details
#initialize ⇒ ArgumentErrorBuilder
3 4 5 6 7 8 9 |
# File 'lib/superstructure/argument_error_builder.rb', line 3 def initialize @errors = { extra_params: [], missing_params: [], shadowed_params: [] } end |
Instance Method Details
#add_error(type, key) ⇒ Object
11 12 13 |
# File 'lib/superstructure/argument_error_builder.rb', line 11 def add_error(type, key) add_errors(type, [key]) end |
#add_errors(type, key) ⇒ Object
15 16 17 |
# File 'lib/superstructure/argument_error_builder.rb', line 15 def add_errors(type, key) @errors.fetch(type).concat(key) end |
#build ⇒ Object
19 20 21 |
# File 'lib/superstructure/argument_error_builder.rb', line 19 def build ArgumentError.new(@errors) end |
#error? ⇒ Boolean
23 24 25 |
# File 'lib/superstructure/argument_error_builder.rb', line 23 def error? @errors.any? { |k, v| v.any? } end |