Sha256: bd6396324f9bd09efcd1b8cfd1d0e2cb320e3c33f1e3e99e064a7a95c98f54e8
Contents?: true
Size: 891 Bytes
Versions: 2
Compression:
Stored size: 891 Bytes
Contents
require 'ripple/associations/proxy' require 'ripple/associations/many' require 'ripple/associations/embedded' module Ripple module Associations class ManyEmbeddedProxy < Proxy include Many include Embedded def <<(docs) load_target @reflection.verify_type!(Array(docs), @owner) assign_references(docs) @target += Array(docs) self end def replace(docs) @reflection.verify_type!(docs, @owner) @_docs = docs.map { |doc| attrs = doc.respond_to?(:attributes_for_persistence) ? doc.attributes_for_persistence : doc } assign_references(docs) reset @_docs end protected def find_target (@_docs || []).map do |attrs| klass.instantiate(attrs).tap do |doc| assign_references(doc) end end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
seomoz-ripple-1.0.0.pre | lib/ripple/associations/many_embedded_proxy.rb |
ripple-1.0.0.beta | lib/ripple/associations/many_embedded_proxy.rb |