Class: Superstructure::ArgumentErrorBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/superstructure/argument_error_builder.rb

Instance Method Summary collapse

Constructor Details

#initializeArgumentErrorBuilder



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

#buildObject



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