Class: Wardrobe::Plugins::Validation::ErrorStore
- Inherits:
-
Object
- Object
- Wardrobe::Plugins::Validation::ErrorStore
- Defined in:
- lib/wardrobe/plugins/validation/error_store.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #add(atr, *errors) ⇒ Object
-
#initialize ⇒ ErrorStore
constructor
A new instance of ErrorStore.
Constructor Details
#initialize ⇒ ErrorStore
Returns a new instance of ErrorStore.
10 11 12 |
# File 'lib/wardrobe/plugins/validation/error_store.rb', line 10 def initialize @store = Hash.new { |hash, key| hash[key] = Array.new } end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
7 8 9 |
# File 'lib/wardrobe/plugins/validation/error_store.rb', line 7 def store @store end |
Instance Method Details
#add(atr, *errors) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/wardrobe/plugins/validation/error_store.rb', line 14 def add(atr, *errors) errors.each do |error| if error.is_a? String @store[atr.name] << error else @store[atr.name].unshift({}) unless @store[atr.name].first.is_a?(Hash) @store[atr.name].first.deep_merge!(error) end end end |