Sha256: 06279a6831b26292b9516de8639040e69575ad5fa8cba5013602fd0ce1dd3f61
Contents?: true
Size: 825 Bytes
Versions: 3
Compression:
Stored size: 825 Bytes
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Associations class ManyEmbeddedPolymorphicProxy < EmbeddedCollection def replace(values) @_values = values.map do |v| v.respond_to?(:attributes) ? v.attributes.merge(association.type_key_name => v.class.name) : v end reset end protected def find_target (@_values || []).map do |hash| child = polymorphic_class(hash).load(hash, true) 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
3 entries across 3 versions & 1 rubygems