Class: Couchbase::Result

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Result

Returns a new instance of Result.



23
24
25
26
27
28
# File 'lib/couchbase/result.rb', line 23

def initialize(attrs = {})
  @bucket    = attrs[:bucket]
  @key       = attrs[:key]
  @operation = attrs[:op]
  @future    = attrs[:future]
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



21
22
23
# File 'lib/couchbase/result.rb', line 21

def error
  @error
end

Instance Method Details

#casObject



52
53
54
# File 'lib/couchbase/result.rb', line 52

def cas
  @future.getCas if @future.respond_to?(:getCas)
end

#keyObject



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

def key
  @key || @future.getKey
end

#nodeObject



56
57
58
# File 'lib/couchbase/result.rb', line 56

def node

end

#operationObject



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

def operation
  @operation
end

#success?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/couchbase/result.rb', line 34

def success?
  @future.get
end

#valueObject



46
47
48
49
50
# File 'lib/couchbase/result.rb', line 46

def value
  @future.get
rescue MultiJson::LoadError
  nil
end