Sha256: df8acc23aa3db531e075f3ca3e7b8e613a343c8b0cd1b51cf3700f8702f49fc4

Contents?: true

Size: 990 Bytes

Versions: 8

Compression:

Stored size: 990 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Document
      extend ActiveSupport::Concern

      module ClassMethods
        def embeddable?
          false
        end
      end

      def new?
        !!(@_new ||= false)
      end

      def destroyed?
        !!(@_destroyed ||= false)
      end

      def reload
        if doc = collection.find({:_id => id},{limit: -1}).first
          self.class.associations.each_value do |association|
            get_proxy(association).reset
          end
          instance_variables.each { |ivar| remove_instance_variable(ivar) }
          initialize_from_database(doc)
          self
        else
          raise DocumentNotFound, "Document match #{_id.inspect} does not exist in #{collection.name} collection"
        end
      end

      # Used by embedded docs to find root easily without if/respond_to? stuff.
      # Documents are always root documents.
      def _root_document
        self
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongo_mapper-0.16.0 lib/mongo_mapper/plugins/document.rb
mongo_mapper-0.15.6 lib/mongo_mapper/plugins/document.rb
mongo_mapper-0.15.5 lib/mongo_mapper/plugins/document.rb
mongo_mapper-0.15.4 lib/mongo_mapper/plugins/document.rb
mongo_mapper-0.15.3 lib/mongo_mapper/plugins/document.rb
mongo_mapper-0.15.2 lib/mongo_mapper/plugins/document.rb
mongo_mapper-0.15.1 lib/mongo_mapper/plugins/document.rb
mongo_mapper-0.15.0 lib/mongo_mapper/plugins/document.rb