class CouchMigrate::CouchPersistedList

Constants

DocName
MigrationField

Public Class Methods

new(database) click to toggle source
Calls superclass method CouchMigrate::BasePersistedList::new
# File lib/couch_migrate/couch_persisted_list.rb, line 9
def initialize(database)
  @db = CouchRest.database!(database) # find or create
  raise "db cannot be created using url #{database}" if @db.nil?
  super()
  self
end

Private Instance Methods

cleanup() click to toggle source
# File lib/couch_migrate/couch_persisted_list.rb, line 28
def cleanup
  @list = []
  write
end
read() click to toggle source
# File lib/couch_migrate/couch_persisted_list.rb, line 18
def read
  @list = @db.get(DocName)[MigrationField] rescue []
end
write() click to toggle source
# File lib/couch_migrate/couch_persisted_list.rb, line 22
def write
  doc = @db.get(DocName) rescue {'_id' => DocName}
  doc[MigrationField] = @list
  @db.save_doc(doc)
end