Class: Tatami::Couch::BulkImport

Inherits:
Object
  • Object
show all
Defined in:
lib/tatami/couch.rb

Instance Method Summary collapse

Constructor Details

#initialize(couch, limit) {|_self| ... } ⇒ BulkImport

Returns a new instance of BulkImport.

Yields:

  • (_self)

Yield Parameters:



214
215
216
217
218
# File 'lib/tatami/couch.rb', line 214

def initialize couch, limit
  @couch, @limit, @cache = couch, limit, []
  yield self
  docs_new
end

Instance Method Details

#doc_new(attributes) ⇒ Object



220
221
222
223
# File 'lib/tatami/couch.rb', line 220

def doc_new attributes
  docs_new if @cache.size > @limit
  @cache << attributes
end

#docs_newObject



225
226
227
228
# File 'lib/tatami/couch.rb', line 225

def docs_new
  @couch.doc_new_bulk @cache
  @cache = []
end