class MarkMapper::Plugins::Associations::EmbeddedCollection
Public Instance Methods
<<(*docs)
click to toggle source
# File lib/mark_mapper/plugins/associations/embedded_collection.rb, line 23 def <<(*docs) load_target docs.each do |doc| assign_references(doc) target << doc end end
build(attributes={})
click to toggle source
# File lib/mark_mapper/plugins/associations/embedded_collection.rb, line 6 def build(attributes={}) doc = klass.new(attributes) assign_references(doc) self << doc doc end
count()
click to toggle source
# File lib/mark_mapper/plugins/associations/embedded_collection.rb, line 18 def count load_target target.size end
find(id)
click to toggle source
# File lib/mark_mapper/plugins/associations/embedded_collection.rb, line 13 def find(id) load_target target.detect { |item| item.id.to_s == id || item.id == id } end
save_to_collection(options={})
click to toggle source
# File lib/mark_mapper/plugins/associations/embedded_collection.rb, line 33 def save_to_collection(options={}) @target.each { |doc| doc.persist(options) } if @target end
Private Instance Methods
assign_references(*docs)
click to toggle source
# File lib/mark_mapper/plugins/associations/embedded_collection.rb, line 38 def assign_references(*docs) docs.each { |doc| doc._parent_document = proxy_owner } end