Sha256: d226e98cc72adfc3ac64d118fe9d686e85317b2c756347b2c4211d9f7897ce8c

Contents?: true

Size: 570 Bytes

Versions: 3

Compression:

Stored size: 570 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Associations
      class ManyEmbeddedProxy < EmbeddedCollection
        def replace(values)
          @_values = (values || []).compact.map do |v|
            v.respond_to?(:attributes) ? v.attributes : v
          end
          reset
        end

        private
          def find_target
            (@_values ||= []).map do |attrs|
              klass.load(attrs, true).tap do |child|
                assign_references(child)
              end
            end
          end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo_mapper-0.13.1 lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb
mongo_mapper-0.13.0 lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb
mongo_mapper-0.13.0.beta2 lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb