Sha256: 17c671fa887be429ffa5477c9b784bb56991f5e70f008c09af686223cc79f28c
Contents?: true
Size: 775 Bytes
Versions: 7
Compression:
Stored size: 775 Bytes
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Associations class OneEmbeddedPolymorphicProxy < OneEmbeddedProxy def replace(value) @value = value.respond_to?(:attributes) ? value.attributes.merge(association.type_key_name => value.class.name) : value reset end protected def find_target if @value child = polymorphic_class(@value).load(@value) assign_references(child) child end end def polymorphic_class(doc) if class_name = doc[association.type_key_name] class_name.constantize else klass end end end end end end
Version data entries
7 entries across 7 versions & 3 rubygems