Sha256: 94ff40f57fc929f8441f6d118adaf456a218163d5bd77c784fc54442812ea6ea
Contents?: true
Size: 828 Bytes
Versions: 11
Compression:
Stored size: 828 Bytes
Contents
module MongoMapper module Associations class BelongsToPolymorphicProxy < Proxy def replace(doc) if doc doc.save if doc.new? id, type = doc._id, doc.class.name end @owner.send("#{@association.foreign_key}=", id) @owner.send("#{@association.type_key_name}=", type) reset end protected def find_target if proxy_id && proxy_class proxy_class.find_by_id(proxy_id) end end def proxy_id @proxy_id ||= @owner.send(@association.foreign_key) end def proxy_class @proxy_class ||= begin klass = @owner.send(@association.type_key_name) klass && klass.constantize end end end end end
Version data entries
11 entries across 11 versions & 4 rubygems