Class: Couchbase::Collection::GetResult

Inherits:
Object
  • Object
show all
Extended by:
Gem::Deprecate
Defined in:
lib/couchbase/collection_options.rb

Direct Known Subclasses

GetReplicaResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|self| ... } ⇒ GetResult

Returns a new instance of GetResult.

Yield Parameters:



65
66
67
68
69
70
# File 'lib/couchbase/collection_options.rb', line 65

def initialize
  @expiry = nil
  @error = nil
  @id = nil
  yield self if block_given?
end

Instance Attribute Details

#cas ⇒ Integer

Returns holds the CAS value of the fetched document.

Returns:

  • (Integer) —

    holds the CAS value of the fetched document



30
31
32
# File 'lib/couchbase/collection_options.rb', line 30

def cas
  @cas
end

#encoded ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The encoded content when loading the document.

Returns:

  • (String) —

    The encoded content when loading the document



48
49
50
# File 'lib/couchbase/collection_options.rb', line 48

def encoded
  @encoded
end

#error ⇒ Error::CouchbaseError?

Returns error associated with the result, or nil (used in Couchbase::Collection#get_multi).

Returns:



36
37
38
# File 'lib/couchbase/collection_options.rb', line 36

def error
  @error
end

#expiry ⇒ Integer

Deprecated.

Returns the expiration if fetched and present.

Returns:

  • (Integer) —

    the expiration if fetched and present



81
82
83
# File 'lib/couchbase/collection_options.rb', line 81

def expiry # rubocop:disable Style/TrivialAccessors will be removed in next major release
  @expiry
end

#flags ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The flags from the operation.

Returns:

  • (Integer) —

    The flags from the operation



74
75
76
# File 'lib/couchbase/collection_options.rb', line 74

def flags
  @flags
end

#id ⇒ String?

Returns identifier of the document (used for Couchbase::Collection#get_multi).

Returns:



39
40
41
# File 'lib/couchbase/collection_options.rb', line 39

def id
  @id
end

#transcoder ⇒ JsonTranscoder

Returns The default transcoder which should be used.

Returns:



77
78
79
# File 'lib/couchbase/collection_options.rb', line 77

def transcoder
  @transcoder
end

Instance Method Details

#content(transcoder = self.transcoder) ⇒ Object

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

Parameters:

  • transcoder (JsonTranscoder) (defaults to: self.transcoder) —

    custom transcoder

Returns:

  • (Object)


55
56
57
# File 'lib/couchbase/collection_options.rb', line 55

def content(transcoder = self.transcoder)
  transcoder ? transcoder.decode(@encoded, @flags) : @encoded
end

#expiry_time ⇒ Time

Returns time when the document will expire.

Returns:

  • (Time) —

    time when the document will expire



60
61
62
# File 'lib/couchbase/collection_options.rb', line 60

def expiry_time
  Time.at(@expiry) if @expiry
end

#success? ⇒ Boolean

Returns true if error was not associated with the result (useful for multi-operations).

Returns:

  • (Boolean) —

    true if error was not associated with the result (useful for multi-operations)



42
43
44
# File 'lib/couchbase/collection_options.rb', line 42

def success?
  !error
end