Class: SimpleValidate::Errors
- Inherits:
-
Object
- Object
- SimpleValidate::Errors
- Defined in:
- lib/simple_validate/errors.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
- #add(attribute, message) ⇒ Object
- #empty? ⇒ Boolean
- #full_messages ⇒ Object
-
#initialize ⇒ Errors
constructor
A new instance of Errors.
- #on(key) ⇒ Object
Constructor Details
#initialize ⇒ Errors
Returns a new instance of Errors.
7 8 9 |
# File 'lib/simple_validate/errors.rb', line 7 def initialize = {} end |
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
5 6 7 |
# File 'lib/simple_validate/errors.rb', line 5 def end |
Instance Method Details
#add(attribute, message) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/simple_validate/errors.rb', line 11 def add(attribute, ) if .key?(attribute) [attribute] << else [attribute] = Array() end end |
#empty? ⇒ Boolean
23 24 25 |
# File 'lib/simple_validate/errors.rb', line 23 def empty? .empty? end |
#full_messages ⇒ Object
27 28 29 |
# File 'lib/simple_validate/errors.rb', line 27 def .values.flatten.map(&:capitalize) end |
#on(key) ⇒ Object
19 20 21 |
# File 'lib/simple_validate/errors.rb', line 19 def on(key) .fetch(key) end |