Sha256: 4071a125d6c44e02233b0cfff9809f630fc60f158a74de6e8071d5f8035d781f
Contents?: true
Size: 874 Bytes
Versions: 2
Compression:
Stored size: 874 Bytes
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Associations class OneEmbeddedProxy < Proxy def build(attributes={}) @target = klass.new(attributes) assign_references(@target) loaded @target end def replace(doc) if doc.respond_to?(:attributes) @target = klass.load(doc.attributes) else @target = klass.load(doc) end assign_references(@target) loaded @target end protected def find_target if @value klass.load(@value).tap do |child| assign_references(child) end end end def assign_references(doc) doc._parent_document = proxy_owner end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongo_mapper-0.8.1 | lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb |
mongo_mapper-0.8.0 | lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb |