Class: MongoMapper::Associations::ManyEmbeddedProxy
- Inherits:
-
Proxy
- Object
- Proxy
- MongoMapper::Associations::ManyEmbeddedProxy
show all
- Defined in:
- lib/mongo_mapper/associations/many_embedded_proxy.rb
Instance Attribute Summary
Attributes inherited from Proxy
#association, #owner
Instance Method Summary
collapse
Methods inherited from Proxy
#initialize, #inspect, #nil?, #reload_target, #reset, #respond_to?, #send
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class MongoMapper::Associations::Proxy
Instance Method Details
#<<(*docs) ⇒ Object
Also known as:
push, concat
21
22
23
24
25
26
27
28
|
# File 'lib/mongo_mapper/associations/many_embedded_proxy.rb', line 21
def <<(*docs)
if load_target
docs.each do |doc|
assign_root_document(doc)
@target << doc
end
end
end
|
#build(attributes = {}) ⇒ Object
9
10
11
12
13
14
|
# File 'lib/mongo_mapper/associations/many_embedded_proxy.rb', line 9
def build(attributes={})
doc = @association.klass.new(attributes)
assign_root_document(doc)
self << doc
doc
end
|
16
17
18
19
|
# File 'lib/mongo_mapper/associations/many_embedded_proxy.rb', line 16
def find(id)
load_target
@target.detect { |item| item.id == id }
end
|
#replace(v) ⇒ Object
4
5
6
7
|
# File 'lib/mongo_mapper/associations/many_embedded_proxy.rb', line 4
def replace(v)
@_values = v.map { |e| e.kind_of?(EmbeddedDocument) ? e.attributes : e }
reset
end
|