Class: Dinamo::Model::Errors

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

Instance Method Summary collapse

Instance Method Details

#add(attribute, message) ⇒ Object



4
5
6
# File 'lib/dinamo/model/errors.rb', line 4

def add(attribute, message)
  fetch(attribute) { self[attribute] = [] } << message
end

#countObject



8
9
10
# File 'lib/dinamo/model/errors.rb', line 8

def count
  values.inject(0) { |all, value| all + value.length }
end

#empty?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/dinamo/model/errors.rb', line 12

def empty?
  count.zero?
end