Class: ShyCouch::Data::CouchDocumentCollection
- Inherits:
-
Array
- Object
- Array
- ShyCouch::Data::CouchDocumentCollection
- Defined in:
- lib/ShyCouch/data.rb
Instance Method Summary collapse
- #<<(obj) ⇒ Object
-
#initialize(opts = {}) ⇒ CouchDocumentCollection
constructor
A new instance of CouchDocumentCollection.
- #pull_all(opts = {}) ⇒ Object
- #pull_all!(opts = {}) ⇒ Object
- #push_all!(opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ CouchDocumentCollection
Returns a new instance of CouchDocumentCollection.
371 372 373 |
# File 'lib/ShyCouch/data.rb', line 371 def initialize(opts = {}) @database = opts[:push_to] if opts[:push_to] end |
Instance Method Details
#<<(obj) ⇒ Object
366 367 368 369 |
# File 'lib/ShyCouch/data.rb', line 366 def << obj raise TypeError unless obj.kind_of?(ShyCouch::Data::CouchDocument) super end |
#pull_all(opts = {}) ⇒ Object
375 376 377 378 379 380 381 382 |
# File 'lib/ShyCouch/data.rb', line 375 def pull_all(opts = {}) opts[:push_to] ? db = opts[:push_to] : db = @database collection = CouchDocumentCollection.new each do |item| collection << db.pull_document(item) end return collection end |
#pull_all!(opts = {}) ⇒ Object
384 385 386 387 388 389 |
# File 'lib/ShyCouch/data.rb', line 384 def pull_all!(opts = {}) opts[:push_to] ? db = opts[:push_to] : db = @database each do |item| item.pull!(:pull_from => db) end end |
#push_all!(opts = {}) ⇒ Object
391 392 393 394 395 396 |
# File 'lib/ShyCouch/data.rb', line 391 def push_all!(opts = {}) opts[:push_to] ? db = opts[:push_to] : db = @database each do |item| item.push!(:push_to => db) end end |