class I18nAdmin::Errors::Collection

Public Instance Methods

add(error_or_type, options = {}) click to toggle source
# File lib/i18n_admin/errors/collection.rb, line 4
def add(error_or_type, options = {})
  error = error_instance_from(error_or_type, options)

  self[error.type] ||= []
  self[error.type] << error
end

Private Instance Methods

error_instance_from(error_or_type, options = {}) click to toggle source
# File lib/i18n_admin/errors/collection.rb, line 13
def error_instance_from(error_or_type, options = {})
  if Symbol === error_or_type
    camelized = error_or_type.to_s.camelize
    type = ['I18nAdmin', 'Errors', camelized].join('::').constantize
    type.new(options)
  else
    error_or_type
  end
end