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.



82
83
84
85
86
# File 'lib/redis/pipeline.rb', line 82

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

Instance Method Details

#_commandObject



97
98
99
# File 'lib/redis/pipeline.rb', line 97

def _command
  @command
end

#_set(object) ⇒ Object



92
93
94
95
# File 'lib/redis/pipeline.rb', line 92

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

#inspectObject



88
89
90
# File 'lib/redis/pipeline.rb', line 88

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

#valueObject



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

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