class Wardrobe::Plugins::Validation::ErrorStore

Attributes

store[R]

Public Class Methods

new() click to toggle source
# File lib/wardrobe/plugins/validation/error_store.rb, line 10
def initialize
  @store = Hash.new { |hash, key| hash[key] = Array.new }
end

Public Instance Methods

add(atr, *errors) click to toggle source
# 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