Sha256: a04c319a81a1fe094704e5cf62e5a7dfb20156b66f94140fa68c5629fbebe599
Contents?: true
Size: 835 Bytes
Versions: 24
Compression:
Stored size: 835 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
24 entries across 24 versions & 6 rubygems