Class: MongoMapper::Plugins::Associations::EmbeddedCollection
- Inherits:
-
Collection
show all
- Defined in:
- lib/novelys_mongo_mapper/plugins/associations/embedded_collection.rb
Instance Attribute Summary
Attributes inherited from Proxy
#owner, #reflection, #target
Instance Method Summary
collapse
Methods inherited from Collection
#reset, #to_ary
Methods inherited from Proxy
#===, #blank?, #initialize, #inspect, #loaded, #loaded?, #nil?, #present?, #proxy_respond_to?, #reload, #replace, #reset, #respond_to?, #send
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class MongoMapper::Plugins::Associations::Proxy
Instance Method Details
#<<(*docs) ⇒ Object
Also known as:
push, concat
22
23
24
25
26
27
28
|
# File 'lib/novelys_mongo_mapper/plugins/associations/embedded_collection.rb', line 22
def <<(*docs)
load_target
docs.each do |doc|
assign_root_document(doc)
target << doc
end
end
|
#build(attributes = {}) ⇒ Object
5
6
7
8
9
10
|
# File 'lib/novelys_mongo_mapper/plugins/associations/embedded_collection.rb', line 5
def build(attributes={})
doc = klass.new(attributes)
assign_root_document(doc)
self << doc
doc
end
|
17
18
19
20
|
# File 'lib/novelys_mongo_mapper/plugins/associations/embedded_collection.rb', line 17
def count
load_target
target.size
end
|
12
13
14
15
|
# File 'lib/novelys_mongo_mapper/plugins/associations/embedded_collection.rb', line 12
def find(id)
load_target
target.detect { |item| item.id.to_s == id || item.id == id }
end
|