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.



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

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

Instance Method Details

#_commandObject



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

def _command
  @command
end

#_set(object) ⇒ Object



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

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

#inspectObject



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

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

#valueObject



125
126
127
128
# File 'lib/redis/pipeline.rb', line 125

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