Sha256: 8bcd601f6719c1b952e83b5c9444443c35c9031e229df88f5182d2a1621a2e93
Contents?: true
Size: 711 Bytes
Versions: 3
Compression:
Stored size: 711 Bytes
Contents
module Compel class Errors def initialize @errors = Hashie::Mash.new end def add(key, error) if error.nil? || error.empty? return end if error.is_a?(Compel::Errors) || error.is_a?(Hash) if @errors[key].nil? @errors[key] = {} end @errors[key].merge!(error.to_hash) else if @errors[key].nil? @errors[key] = [] end if !error.is_a?(Array) error = [error] end @errors[key].concat(error) end @errors end def length @errors.keys.length end def empty? length == 0 end def to_hash @errors end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
compel-0.3.7 | lib/compel/errors.rb |
compel-0.3.6 | lib/compel/errors.rb |
compel-0.3.4 | lib/compel/errors.rb |