Class: Hubspot::Errors

Inherits:
Hash
  • Object
show all
Defined in:
lib/hubspot/errors.rb

Instance Method Summary collapse

Instance Method Details

#add(key, value, _opts = {}) ⇒ Object



3
4
5
6
7
# File 'lib/hubspot/errors.rb', line 3

def add(key, value, _opts = {})
  self[key] ||= []
  self[key] << value
  self[key].uniq!
end

#add_multiple_errors(errors_hash) ⇒ Object



9
10
11
12
13
# File 'lib/hubspot/errors.rb', line 9

def add_multiple_errors(errors_hash)
  errors_hash.each do |key, values|
    errors_hash[key].each { |value| add(key, value) }
  end
end

#eachObject



15
16
17
18
19
# File 'lib/hubspot/errors.rb', line 15

def each
  each_key do |field|
    self[field].each { |message| yield field, message }
  end
end