Class: Servicify::Common::Errors

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

Instance Method Summary collapse

Instance Method Details

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



4
5
6
7
8
# File 'lib/servicify/common/errors.rb', line 4

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

#add_multiple_errors(errors_hash) ⇒ Object



10
11
12
13
14
# File 'lib/servicify/common/errors.rb', line 10

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

#eachObject



16
17
18
19
20
# File 'lib/servicify/common/errors.rb', line 16

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