Sha256: b876efc5d4b818405a822eec6e7a3a516f3c7bf7b17effcf079d05fac0715ea1

Contents?: true

Size: 538 Bytes

Versions: 3

Compression:

Stored size: 538 Bytes

Contents

module TheNotification
  module LocalizedErrors
    extend ActiveSupport::Concern

    # include TheNotification::LocalizedErrors

    # @post.localized_errors(except: [:'comment.title'])
    def localized_errors opts = {}
      opts.symbolize_keys!
      excepts = opts.delete(:except) || []

      errors.inject({}) do |hash, (k, v)|
        unless excepts.include?(k.to_sym)
          k = self.class.human_attribute_name k
          hash[k].blank? ? hash[k] = [v] : hash[k].push(v)
        end
        hash
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
the_notification-0.5.1 app/models/concerns/localized_errors.rb
the_notification-0.5.0 app/models/concerns/localized_errors.rb
the_notification-0.0.1 app/models/concerns/localized_errors.rb