Sha256: 1626861a4112bc4bb61eda1edc634759c864f73e485a0e1f871b250f2ba6c2de

Contents?: true

Size: 709 Bytes

Versions: 6

Compression:

Stored size: 709 Bytes

Contents

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

    # Raised when querying the database for a document by a specific id which
    # does not exist. If multiple ids were passed then it will display all of
    # those.
    #
    # Example:
    #
    # <tt>DocumentNotFound.new(Person, ["1", "2"])</tt>
    class DocumentNotFound < MongoidError

      attr_reader :klass, :indentifiers

      def initialize(klass, ids)
        @klass = klass
        @identifiers = ids.is_a?(Array) ? ids.join(", ") : ids

        super(
          translate(
            "document_not_found",
            { :klass => klass.name, :identifiers => @identifiers }
          )
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-2.0.0.rc.1 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.beta.20 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.beta.19 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.beta.18 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.beta.17 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.beta.16 lib/mongoid/errors/document_not_found.rb