Class: Redis::Future

Inherits:
BasicObject
Defined in:
lib/redis/pipeline.rb

Direct Known Subclasses

MultiFuture

Constant Summary collapse

FutureNotReady =
::Redis::FutureNotReady.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, transformation, timeout) ⇒ Future

Returns a new instance of Future.



249
250
251
252
253
254
# File 'lib/redis/pipeline.rb', line 249

def initialize(command, transformation, timeout)
  @command = command
  @transformation = transformation
  @timeout = timeout
  @object = FutureNotReady
end

Instance Attribute Details

#timeoutObject (readonly)

Returns the value of attribute timeout.



247
248
249
# File 'lib/redis/pipeline.rb', line 247

def timeout
  @timeout
end

Instance Method Details

#==(_other) ⇒ Object



256
257
258
259
260
261
262
263
264
# File 'lib/redis/pipeline.rb', line 256

def ==(_other)
  message = +"The methods == and != are deprecated for Redis::Future and will be removed in 5.0.0"
  message << " - You probably meant to call .value == or .value !="
  message << " (#{::Kernel.caller(1, 1).first})\n"

  ::Redis.deprecate!(message)

  super
end

#_commandObject



275
276
277
# File 'lib/redis/pipeline.rb', line 275

def _command
  @command
end

#_set(object) ⇒ Object



270
271
272
273
# File 'lib/redis/pipeline.rb', line 270

def _set(object)
  @object = @transformation ? @transformation.call(object) : object
  value
end

#classObject



288
289
290
# File 'lib/redis/pipeline.rb', line 288

def class
  Future
end

#inspectObject



266
267
268
# File 'lib/redis/pipeline.rb', line 266

def inspect
  "<Redis::Future #{@command.inspect}>"
end

#is_a?(other) ⇒ Boolean

Returns:

  • (Boolean)


284
285
286
# File 'lib/redis/pipeline.rb', line 284

def is_a?(other)
  self.class.ancestors.include?(other)
end

#valueObject



279
280
281
282
# File 'lib/redis/pipeline.rb', line 279

def value
  ::Kernel.raise(@object) if @object.is_a?(::RuntimeError)
  @object
end