Class: SexyValidations::Errors

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

Instance Method Summary collapse

Instance Method Details

#[](k) ⇒ Object



3
4
5
# File 'lib/sexy_validations/errors.rb', line 3

def [](k)
  has_key?(k) ? super : (self[k] = [])
end

#add(att, msg) ⇒ Object



7
8
9
# File 'lib/sexy_validations/errors.rb', line 7

def add(att, msg)
  self[att] << msg
end

#countObject



11
12
13
# File 'lib/sexy_validations/errors.rb', line 11

def count
  values.inject(0){ |m, v| m+v.length }
end

#empty?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/sexy_validations/errors.rb', line 15

def empty?
  count == 0
end