Class: Redis::Future

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

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.



138
139
140
141
142
143
# File 'lib/redis/pipeline.rb', line 138

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.



136
137
138
# File 'lib/redis/pipeline.rb', line 136

def timeout
  @timeout
end

Instance Method Details

#==(_other) ⇒ Object



145
146
147
148
149
150
151
152
153
# File 'lib/redis/pipeline.rb', line 145

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

  ::Kernel.warn(message)

  super
end

#_commandObject



164
165
166
# File 'lib/redis/pipeline.rb', line 164

def _command
  @command
end

#_set(object) ⇒ Object



159
160
161
162
# File 'lib/redis/pipeline.rb', line 159

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

#classObject



177
178
179
# File 'lib/redis/pipeline.rb', line 177

def class
  Future
end

#inspectObject



155
156
157
# File 'lib/redis/pipeline.rb', line 155

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

#is_a?(other) ⇒ Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/redis/pipeline.rb', line 173

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

#valueObject



168
169
170
171
# File 'lib/redis/pipeline.rb', line 168

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