Sha256: 8424a1db375f800f19910085bf736efaf3c49d96927a89661a31dabc5e7df93e
Contents?: true
Size: 697 Bytes
Versions: 5
Compression:
Stored size: 697 Bytes
Contents
module Compel class Errors def initialize @errors = {} 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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
compel-0.5.1 | lib/compel/errors.rb |
compel-0.5.0 | lib/compel/errors.rb |
compel-0.4.3 | lib/compel/errors.rb |
compel-0.4.2 | lib/compel/errors.rb |
compel-0.4.0 | lib/compel/errors.rb |