Sha256: 0eeee0ddae365f698e5f1f34080c0016488d7324d4e66e8e817f192895502b33
Contents?: true
Size: 804 Bytes
Versions: 2
Compression:
Stored size: 804 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[association.foreign_key] = id owner[association.type_key_name] = type reset end protected def find_target return nil if association_class.nil? || owner[association.foreign_key].nil? association_class.find_by_id(owner[association.foreign_key]) end def association_class proxy_owner[association.type_key_name] ? proxy_owner[association.type_key_name].constantize : nil end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
pwnash-mongo_mapper-0.7.5 | lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb |
mongo_mapper-0.7.6 | lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb |