Class: Redis2::Future

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

Constant Summary collapse

FutureNotReady =
::Redis2::FutureNotReady.new

Instance Method Summary collapse

Constructor Details

#initialize(command, transformation) ⇒ Future

Returns a new instance of Future.



109
110
111
112
113
# File 'lib/redis2/pipeline.rb', line 109

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

Instance Method Details

#_commandObject



124
125
126
# File 'lib/redis2/pipeline.rb', line 124

def _command
  @command
end

#_set(object) ⇒ Object



119
120
121
122
# File 'lib/redis2/pipeline.rb', line 119

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

#classObject



137
138
139
# File 'lib/redis2/pipeline.rb', line 137

def class
  Future
end

#inspectObject



115
116
117
# File 'lib/redis2/pipeline.rb', line 115

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

#is_a?(other) ⇒ Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/redis2/pipeline.rb', line 133

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

#valueObject



128
129
130
131
# File 'lib/redis2/pipeline.rb', line 128

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