Sha256: 92164afa80f5a3e203a5355c9d60278a8cf0e89a84bea7d108d414b92c29351e

Contents?: true

Size: 974 Bytes

Versions: 6

Compression:

Stored size: 974 Bytes

Contents

# encoding: UTF-8
module MarkMapper
  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_one(:_id => id)
          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

6 entries across 6 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 lib/mark_mapper/plugins/document.rb
mark_mapper-0.0.5 lib/mark_mapper/plugins/document.rb
mark_mapper-0.0.4 lib/mark_mapper/plugins/document.rb
mark_mapper-0.0.3 lib/mark_mapper/plugins/document.rb
mark_mapper-0.0.2 lib/mark_mapper/plugins/document.rb
mark_mapper-0.0.1 lib/mark_mapper/plugins/document.rb