Sha256: 07df9397fb75b0686d6a66d07c80faca608a22c1b9d7f8dfc3efd61a24221ecb

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc
  module Errors #:nodoc

    # Default parent Mongoid error for all custom errors. This handles the base
    # key for the translations and provides the convenience method for
    # translating the messages.
    class MongoidError < StandardError
      BASE_KEY = "mongoid.errors.messages"

      # Given the key of the specific error and the options hash, translate the
      # message.
      #
      # Options:
      #
      # key: The key of the error in the locales.
      # options: The objects to pass to create the message.
      #
      # Returns:
      #
      # A localized error message string.
      def translate(key, options)
        I18n.translate("#{BASE_KEY}.#{key}", options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-2.0.0.beta.16 lib/mongoid/errors/mongoid_error.rb