Method: Couchbase::ViewRow#initialize

Defined in:
lib/couchbase/view_row.rb

#initialize(bucket, data) ⇒ ViewRow

Initialize the document instance

It takes reference to the bucket, data hash.

Parameters:

  • bucket (Couchbase::Bucket)

    the reference to connection

  • data (Hash)

    the data hash, which was built from JSON document representation

Since:

  • 1.2.0



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/couchbase/view_row.rb', line 96

def initialize(bucket, data)
  @bucket = bucket
  @data = data
  @key = data[S_KEY]
  @value = data[S_VALUE]
  if data[S_DOC]
    @meta = data[S_DOC][S_META]
    @doc = data[S_DOC][S_VALUE]
  end
  @id = data[S_ID] || @meta && @meta[S_ID]
  @last = data.delete(S_IS_LAST) || false
end