Class: GOM::Storage::CouchDB::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/gom/storage/couchdb/fetcher.rb

Overview

Fetches a CouchDB document with the given id and returns a draft.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database, id, revisions) ⇒ Fetcher

Returns a new instance of Fetcher.



9
10
11
# File 'lib/gom/storage/couchdb/fetcher.rb', line 9

def initialize(database, id, revisions)
  @database, @id, @revisions = database, id, revisions
end

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



5
6
7
# File 'lib/gom/storage/couchdb/fetcher.rb', line 5

def database
  @database
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/gom/storage/couchdb/fetcher.rb', line 6

def id
  @id
end

#revisionsObject

Returns the value of attribute revisions.



7
8
9
# File 'lib/gom/storage/couchdb/fetcher.rb', line 7

def revisions
  @revisions
end

Instance Method Details

#draftObject



13
14
15
16
17
18
19
20
# File 'lib/gom/storage/couchdb/fetcher.rb', line 13

def draft
  initialize_document
  load_document
  build_draft
  @draft
rescue ::CouchDB::Document::NotFoundError
  nil
end