Sha256: d5e31edfb855968a4fe92a516e9f960f8552bbd7980f063a59451a83bac22ec7
Contents?: true
Size: 725 Bytes
Versions: 3
Compression:
Stored size: 725 Bytes
Contents
module DataMapper class ValidationErrors def initialize @errors = Hash.new { |h,k| h[k.to_sym] = [] } end # Clear existing validation errors. def clear! @errors.clear end # Add a validation error. Use the attribute :general if # the error doesn't apply to a specific attribute. def add(attribute, message) @errors[attribute] << message end # Collect all errors into a single list. def full_messages @errors.inject([]) do |list,pair| list += pair.last end end def on(attribute) @errors[attribute] end def method_missing(meth, *args) @errors.send(meth, *args) end end end
Version data entries
3 entries across 3 versions & 1 rubygems