Class: Interfacets::Shared::Validations::Errors
- Inherits:
-
Object
- Object
- Interfacets::Shared::Validations::Errors
- Includes:
- Enumerable
- Defined in:
- lib/interfacets/shared/validations.rb
Instance Method Summary collapse
- #[](k) ⇒ Object
- #add(k, v) ⇒ Object
- #clear ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Errors
constructor
A new instance of Errors.
Constructor Details
#initialize ⇒ Errors
Returns a new instance of Errors.
11 12 13 |
# File 'lib/interfacets/shared/validations.rb', line 11 def initialize @errors = Hash.new { |h, k| h[k] = [] } end |
Instance Method Details
#[](k) ⇒ Object
23 24 25 |
# File 'lib/interfacets/shared/validations.rb', line 23 def [](k) @errors[k] end |
#add(k, v) ⇒ Object
15 16 17 |
# File 'lib/interfacets/shared/validations.rb', line 15 def add(k, v) @errors[k.to_sym] << v end |
#clear ⇒ Object
19 20 21 |
# File 'lib/interfacets/shared/validations.rb', line 19 def clear @errors.clear end |
#each ⇒ Object
27 28 29 |
# File 'lib/interfacets/shared/validations.rb', line 27 def each(...) @errors.each(...) end |
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/interfacets/shared/validations.rb', line 31 def empty? @errors.all? { _2.empty? } end |