Sha256: 3ae35f6621b821e44fc3c3a3318b9b438b414917246ab48f8f6c7988738fc26e
Contents?: true
Size: 1003 Bytes
Versions: 1
Compression:
Stored size: 1003 Bytes
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Document module ClassMethods def embeddable? false end end module InstanceMethods def new? @_new end def destroyed? @_destroyed == true end def reload if doc = self.class.query.find_one(:_id => id) tap do |instance| instance.class.associations.each_key do |association_name| send(association_name).reset if respond_to?(association_name) end instance.attributes = doc end 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo_mapper-0.8.0 | lib/mongo_mapper/plugins/document.rb |