Class: Couchbase::Async::Callback

Inherits:
Object
  • Object
show all
Includes:
Java::NetSpyMemcachedInternal::OperationCompletionListener
Defined in:
lib/couchbase/async/callback.rb

Instance Method Summary collapse

Constructor Details

#initialize(operation, &callback) ⇒ Callback

Returns a new instance of Callback.



6
7
8
# File 'lib/couchbase/async/callback.rb', line 6

def initialize(operation, &callback)
  @operation, @callback = operation, callback
end

Instance Method Details

#onComplete(future) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/couchbase/async/callback.rb', line 10

def onComplete(future)
  result = Couchbase::Result.new(operation: @operation, future: future)
  @callback.call(result)
rescue Exception => e
  result.error = e
  return result
end