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.



103
104
105
106
107
# File 'lib/redis/pipeline.rb', line 103

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

Instance Method Details

#_commandObject



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

def _command
  @command
end

#_set(object) ⇒ Object



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

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

#classObject



131
132
133
# File 'lib/redis/pipeline.rb', line 131

def class
  Future
end

#inspectObject



109
110
111
# File 'lib/redis/pipeline.rb', line 109

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

#is_a?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#valueObject



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

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