Module: MongoMapper::Plugins::Document
- Extended by:
- ActiveSupport::Concern
- Included in:
- Document
- Defined in:
- lib/mongo_mapper/plugins/document.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#_root_document ⇒ Object
Used by embedded docs to find root easily without if/respond_to? stuff.
- #destroyed? ⇒ Boolean
- #new? ⇒ Boolean
- #reload ⇒ Object
Instance Method Details
#_root_document ⇒ Object
Used by embedded docs to find root easily without if/respond_to? stuff. Documents are always root documents.
36 37 38 |
# File 'lib/mongo_mapper/plugins/document.rb', line 36 def _root_document self end |
#destroyed? ⇒ Boolean
17 18 19 |
# File 'lib/mongo_mapper/plugins/document.rb', line 17 def destroyed? !!(@_destroyed ||= false) end |
#new? ⇒ Boolean
13 14 15 |
# File 'lib/mongo_mapper/plugins/document.rb', line 13 def new? !!(@_new ||= false) end |
#reload ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mongo_mapper/plugins/document.rb', line 21 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 |