Class: Couchbase::Collection::GetResult

Inherits:
Object
  • Object
show all
Extended by:
Gem::Deprecate
Defined in:
lib/couchbase/collection_options.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/collection_options.rb
more...

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:

[View source]

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

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

Instance Attribute Details

#casInteger

Returns holds the CAS value of the fetched document.

Returns:

  • (Integer)

    holds the CAS value of the fetched document


27
28
29
# File 'lib/couchbase/collection_options.rb', line 27

def cas
  @cas
end

#errorError::CouchbaseError?

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

Returns:


33
34
35
# File 'lib/couchbase/collection_options.rb', line 33

def error
  @error
end

#expiryInteger

Deprecated.

Returns the expiration if fetched and present.

Returns:

  • (Integer)

    the expiration if fetched and present


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

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

#transcoderJsonTranscoder

Returns The default transcoder which should be used.

Returns:


70
71
72
# File 'lib/couchbase/collection_options.rb', line 70

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)
[View source]

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

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

#expiry_timeTime

Returns time when the document will expire.

Returns:

  • (Time)

    time when the document will expire

[View source]

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

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)

[View source]

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

def success?
  !error
end