module MongoModel::Attributes::ClassMethods
Public Instance Methods
from_mongo(hash)
click to toggle source
# File lib/mongomodel/concerns/attributes.rb, line 73 def from_mongo(hash) if hash doc = class_for_type(hash['_type']).new doc.attributes.load!(hash) doc end end
Private Instance Methods
class_for_type(type)
click to toggle source
# File lib/mongomodel/concerns/attributes.rb, line 82 def class_for_type(type) klass = type.constantize if klass.ancestors.map(&:name).include?(name) klass else raise DocumentNotFound, "Document not of the correct type (got #{type})" end rescue NameError self end