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.



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

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.



134
135
136
# File 'lib/redis/pipeline.rb', line 134

def timeout
  @timeout
end

Instance Method Details

#==(_other) ⇒ Object



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

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"

  if defined?(::Warning)
    ::Warning.warn(message)
  else
    $stderr.puts(message)
  end

  super
end

#_commandObject



166
167
168
# File 'lib/redis/pipeline.rb', line 166

def _command
  @command
end

#_set(object) ⇒ Object



161
162
163
164
# File 'lib/redis/pipeline.rb', line 161

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

#classObject



179
180
181
# File 'lib/redis/pipeline.rb', line 179

def class
  Future
end

#inspectObject



157
158
159
# File 'lib/redis/pipeline.rb', line 157

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

#is_a?(other) ⇒ Boolean

Returns:

  • (Boolean)


175
176
177
# File 'lib/redis/pipeline.rb', line 175

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

#valueObject



170
171
172
173
# File 'lib/redis/pipeline.rb', line 170

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