Sha256: 6beb5231b9c54d993ca2efa56eb0ea410d4a583e410e0b28d5f0aaa97a7020a1

Contents?: true

Size: 765 Bytes

Versions: 17

Compression:

Stored size: 765 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

17 entries across 17 versions & 3 rubygems

Version Path
mongoid-braxton-2.0.2 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.2 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.1 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.rc.8 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.rc.7 lib/mongoid/errors/mongoid_error.rb
stonegao-mongoid-2.0.0.rc.6 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.rc.6 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.rc.5 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.rc.4 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.rc.3 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.rc.2 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.rc.1 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.beta.20 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.beta.19 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.beta.18 lib/mongoid/errors/mongoid_error.rb
mongoid-2.0.0.beta.17 lib/mongoid/errors/mongoid_error.rb