Class: CouchClient::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/couch-client/collection.rb

Overview

Collection is an extended Array that provides additional methods and state to get status codes, info and connect documents to the server.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, body, connection) ⇒ Collection

Collection is constructed with a status code, response body, and connection object.



9
10
11
12
13
14
15
16
17
18
# File 'lib/couch-client/collection.rb', line 9

def initialize(code, body, connection)
  # Iterate over each row to set them a CouchClient::Row object.
  body.delete("rows").each.with_index do |row, idx|
    self[idx] = Row.new(code, row, connection)
  end

  @code = code
  @info = body
  @connection = connection
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/couch-client/collection.rb', line 5

def code
  @code
end

#infoObject (readonly)

Returns the value of attribute info.



5
6
7
# File 'lib/couch-client/collection.rb', line 5

def info
  @info
end