Class: Mongo::DelegatingCollection
- Inherits:
-
Object
- Object
- Mongo::DelegatingCollection
- Includes:
- CollMod, FromHash
- Defined in:
- lib/mongo_delegate/delegating_collection.rb
Instance Attribute Summary collapse
-
#local ⇒ Object
Returns the value of attribute local.
-
#remote ⇒ Object
Returns the value of attribute remote.
Instance Method Summary collapse
- #colls ⇒ Object
- #find(selector = {}, options = {}) ⇒ Object
- #find_one(selector = {}, options = {}) ⇒ Object
- #remove ⇒ Object
- #save(d) ⇒ Object
Methods included from CollMod
Instance Attribute Details
#local ⇒ Object
Returns the value of attribute local.
14 15 16 |
# File 'lib/mongo_delegate/delegating_collection.rb', line 14 def local @local end |
#remote ⇒ Object
Returns the value of attribute remote.
14 15 16 |
# File 'lib/mongo_delegate/delegating_collection.rb', line 14 def remote @remote end |
Instance Method Details
#colls ⇒ Object
24 25 26 |
# File 'lib/mongo_delegate/delegating_collection.rb', line 24 def colls [local,remote] end |
#find(selector = {}, options = {}) ⇒ Object
15 16 17 |
# File 'lib/mongo_delegate/delegating_collection.rb', line 15 def find(selector={},={}) CompositeCursor.new(:colls => [local,remote],:selector => selector, :options => ) end |
#find_one(selector = {}, options = {}) ⇒ Object
18 19 20 |
# File 'lib/mongo_delegate/delegating_collection.rb', line 18 def find_one(selector = {}, = {}) find(selector,.merge(:limit => 1)).first end |
#remove ⇒ Object
21 22 23 |
# File 'lib/mongo_delegate/delegating_collection.rb', line 21 def remove colls.each { |x| x.remove } end |
#save(d) ⇒ Object
27 28 29 30 |
# File 'lib/mongo_delegate/delegating_collection.rb', line 27 def save(d) d = d.merge('_duplicate' => true) if d['_id'] && remote.find_one('_id' => d['_id']) local.save(d) end |