Class: Helene::Sdb::Base::Validations::Errors
- Defined in:
- lib/helene/sdb/base/validations.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
- #_dump(*a) ⇒ Object
- #add(att, msg) ⇒ Object
- #count ⇒ Object
- #full_messages ⇒ Object
-
#initialize(object = nil) ⇒ Errors
constructor
A new instance of Errors.
- #message ⇒ Object
- #on(att) ⇒ Object
Methods inherited from Hash
Constructor Details
#initialize(object = nil) ⇒ Errors
Returns a new instance of Errors.
56 57 58 59 60 |
# File 'lib/helene/sdb/base/validations.rb', line 56 def initialize object = nil @object = object block = lambda{|h,k| h[k] = []} super(&block) end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
51 52 53 |
# File 'lib/helene/sdb/base/validations.rb', line 51 def object @object end |
Class Method Details
Instance Method Details
#_dump(*a) ⇒ Object
66 67 68 |
# File 'lib/helene/sdb/base/validations.rb', line 66 def _dump(*a) Marshal.dump({}.update(to_hash)) end |
#add(att, msg) ⇒ Object
78 79 80 |
# File 'lib/helene/sdb/base/validations.rb', line 78 def add(att, msg) self[att] << msg end |
#count ⇒ Object
70 71 72 |
# File 'lib/helene/sdb/base/validations.rb', line 70 def count size end |
#full_messages ⇒ Object
82 83 84 85 86 87 |
# File 'lib/helene/sdb/base/validations.rb', line 82 def inject([]) do |m, kv| att, errors = *kv errors.each {|e| m << "#{att} #{e}"} m end end |
#message ⇒ Object
89 90 91 |
# File 'lib/helene/sdb/base/validations.rb', line 89 def .join(' | ') end |
#on(att) ⇒ Object
74 75 76 |
# File 'lib/helene/sdb/base/validations.rb', line 74 def on(att) self[att] end |