Class: Redis::Future

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

Constant Summary collapse

FutureNotReady =
::Redis::FutureNotReady.new

Instance Method Summary collapse

Constructor Details

#initialize(command, transformation) ⇒ Future

Returns a new instance of Future.



101
102
103
104
105
# File 'lib/redis/pipeline.rb', line 101

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

Instance Method Details

#_commandObject



116
117
118
# File 'lib/redis/pipeline.rb', line 116

def _command
  @command
end

#_set(object) ⇒ Object



111
112
113
114
# File 'lib/redis/pipeline.rb', line 111

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

#inspectObject



107
108
109
# File 'lib/redis/pipeline.rb', line 107

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

#valueObject



120
121
122
123
# File 'lib/redis/pipeline.rb', line 120

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