Sha256: be79e2dd0b1d89fb891310e6db11b3d3c80fc3fccc0522c702544c02c30dbca6
Contents?: true
Size: 801 Bytes
Versions: 3
Compression:
Stored size: 801 Bytes
Contents
module MongoMapper module Plugins module Associations class ManyEmbeddedPolymorphicProxy < EmbeddedCollection def replace(values) @_values = values.map do |v| v.respond_to?(:attributes) ? v.attributes.merge(reflection.type_key_name => v.class.name) : v end reset end protected def find_target (@_values || []).map do |hash| child = polymorphic_class(hash).new(hash) assign_root_document(child) child end end def polymorphic_class(doc) if class_name = doc[reflection.type_key_name] class_name.constantize else klass end end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems