Sha256: a11aa2930ff2ab84c610e72ea6153de7cae71f451c4437196f590791c7fd953b
Contents?: true
Size: 851 Bytes
Versions: 1
Compression:
Stored size: 851 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) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo_mapper_ign-0.7.8 | lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb |