Method: CouchClient::Document#initialize

Defined in:
lib/couch-client/document.rb

#initialize(code, body, connection, deleted = false) ⇒ Document

Document is constructed with a status code, response body, connection object and a flag stating if the document has been deleted.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/couch-client/document.rb', line 13

def initialize(code, body, connection, deleted = false)
  self.merge!(body)

  @code = code
  @error = {}
  @connection = connection
  @deleted = deleted

  if self.attachments
    self.attachments = AttachmentList.new(attachments)
    
    self.attachments.keys.each do |key|
      self.attachments[key] = Attachment.new(id, key, attachments[key], @connection)
    end
  end
end