Sha256: d3262eb6a09b3a71cd8a4957383e5e5cd7f15b68be726b7f49299e78606c3bca
Contents?: true
Size: 806 Bytes
Versions: 22
Compression:
Stored size: 806 Bytes
Contents
module MongoMapper module Plugins module Associations class BelongsToPolymorphicProxy < Proxy undef_method :object_id def replace(doc) if doc doc.save if doc.new? id, type = doc.id, doc.class.name end owner[reflection.foreign_key] = id owner[reflection.type_key_name] = type reset end protected def find_target return nil if association_class.nil? || owner[reflection.foreign_key].nil? association_class.find_by_id(owner[reflection.foreign_key]) end def association_class proxy_owner[reflection.type_key_name] ? proxy_owner[reflection.type_key_name].constantize : nil end end end end end
Version data entries
22 entries across 22 versions & 3 rubygems