Sha256: 44e192ce1fef2b8af3dfacdd463835374b44dbf8b6baefa62c7b7a4124f85887

Contents?: true

Size: 708 Bytes

Versions: 12

Compression:

Stored size: 708 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, :identifiers

      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

12 entries across 12 versions & 3 rubygems

Version Path
mongoid-braxton-2.0.2 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.2 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.1 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.rc.8 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.rc.7 lib/mongoid/errors/document_not_found.rb
stonegao-mongoid-2.0.0.rc.6 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.rc.6 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.rc.5 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.rc.4 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.rc.3 lib/mongoid/errors/document_not_found.rb
mongoid-2.0.0.rc.2 lib/mongoid/errors/document_not_found.rb