Class: Couchbase::Collection::ScanResult

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/collection_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, id_only:, cas: nil, expiry: nil, encoded: nil, flags: nil, transcoder: JsonTranscoder.new) {|_self| ... } ⇒ ScanResult

Returns a new instance of ScanResult.

Yields:

  • (_self)

Yield Parameters:



340
341
342
343
344
345
346
347
348
349
350
# File 'lib/couchbase/collection_options.rb', line 340

def initialize(id:, id_only:, cas: nil, expiry: nil, encoded: nil, flags: nil, transcoder: JsonTranscoder.new)
  @id = id
  @id_only = id_only
  @cas = cas
  @expiry = expiry
  @encoded = encoded
  @flags = flags
  @transcoder = transcoder

  yield self if block_given?
end

Instance Attribute Details

#casInteger?

Returns holds the CAS value of the fetched document.

Returns:

  • (Integer, nil)

    holds the CAS value of the fetched document



331
332
333
# File 'lib/couchbase/collection_options.rb', line 331

def cas
  @cas
end

#expiryInteger?

Returns the expiration if fetched and present.

Returns:

  • (Integer, nil)

    the expiration if fetched and present



334
335
336
# File 'lib/couchbase/collection_options.rb', line 334

def expiry
  @expiry
end

#idString

Returns identifier of the document.

Returns:

  • (String)

    identifier of the document



325
326
327
# File 'lib/couchbase/collection_options.rb', line 325

def id
  @id
end

#id_onlyBoolean

Returns whether only ids are returned from this scan.

Returns:

  • (Boolean)

    whether only ids are returned from this scan



328
329
330
# File 'lib/couchbase/collection_options.rb', line 328

def id_only
  @id_only
end

#transcoderJsonTranscoder, ...

Returns The default transcoder which should be used.

Returns:



338
339
340
# File 'lib/couchbase/collection_options.rb', line 338

def transcoder
  @transcoder
end

Instance Method Details

#content(transcoder = self.transcoder) ⇒ Object?

Decodes the content of the document using given (or default transcoder)

Parameters:

Returns:

  • (Object, nil)


357
358
359
360
361
# File 'lib/couchbase/collection_options.rb', line 357

def content(transcoder = self.transcoder)
  return nil if @encoded.nil?

  transcoder ? transcoder.decode(@encoded, @flags) : @encoded
end