class Volt::Errors

Public Instance Methods

add(field, error) click to toggle source
# File lib/volt/models/errors.rb, line 5
def add(field, error)
  field_errors = (self[field] ||= [])
  field_errors << error unless field_errors.include?(error)
end
merge!(errors) click to toggle source

Merge another set of errors in

# File lib/volt/models/errors.rb, line 11
def merge!(errors)
  if errors
    errors.each_pair do |field, messages|
      messages.each do |message|
        add(field, message)
      end
    end
  end
end
to_s() click to toggle source

Generate a string version of all of the errors

# File lib/volt/models/errors.rb, line 22
def to_s
  str = []

  each_pair do |field, error|
    str << "#{field} #{error}"
  end

  str.join(', ')
end