class MarkMapper::Plugins::Associations::OneEmbeddedProxy
Public Instance Methods
build(attributes={})
click to toggle source
# File lib/mark_mapper/plugins/associations/one_embedded_proxy.rb, line 6 def build(attributes={}) @target = klass.new(attributes) assign_references(@target) loaded @target end
replace(doc)
click to toggle source
# File lib/mark_mapper/plugins/associations/one_embedded_proxy.rb, line 13 def replace(doc) if doc.respond_to?(:attributes) @target = klass.load(doc.attributes, true) else @target = klass.load(doc, true) end assign_references(@target) loaded @target end
save_to_collection(options={})
click to toggle source
# File lib/mark_mapper/plugins/associations/one_embedded_proxy.rb, line 24 def save_to_collection(options={}) @target.persist(options) if @target end
Protected Instance Methods
assign_references(doc)
click to toggle source
# File lib/mark_mapper/plugins/associations/one_embedded_proxy.rb, line 38 def assign_references(doc) doc._parent_document = proxy_owner if doc end
find_target()
click to toggle source
# File lib/mark_mapper/plugins/associations/one_embedded_proxy.rb, line 30 def find_target if @value klass.load(@value, true).tap do |child| assign_references(child) end end end