Class: Veto::Errors
- Inherits:
-
Hash
- Object
- Hash
- Veto::Errors
- Defined in:
- lib/veto/errors.rb
Instance Method Summary collapse
- #add(atr, msg, *msg_opts) ⇒ Object
- #count ⇒ Object
- #empty? ⇒ Boolean
- #full_messages ⇒ Object
- #on(atr) ⇒ Object
Instance Method Details
#add(atr, msg, *msg_opts) ⇒ Object
3 4 5 |
# File 'lib/veto/errors.rb', line 3 def add(atr, msg, *msg_opts) fetch(atr){self[atr] = []} << msg_lookup(msg, *msg_opts) end |
#count ⇒ Object
7 8 9 |
# File 'lib/veto/errors.rb', line 7 def count values.inject(0){|m, v| m + v.length} end |
#empty? ⇒ Boolean
11 12 13 |
# File 'lib/veto/errors.rb', line 11 def empty? count == 0 end |
#full_messages ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/veto/errors.rb', line 15 def inject([]) do |m, kv| atr, errors = *kv errors.each {|e| m << "#{atr} #{e}"} m end end |
#on(atr) ⇒ Object
23 24 25 26 27 |
# File 'lib/veto/errors.rb', line 23 def on(atr) if v = fetch(atr, nil) and !v.empty? v end end |