Class: MockRedis::Future

Inherits:
Object
  • Object
show all
Defined in:
lib/mock_redis/future.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, block = nil) ⇒ Future

Returns a new instance of Future.



7
8
9
10
11
# File 'lib/mock_redis/future.rb', line 7

def initialize(command, block = nil)
  @command = command
  @block = block
  @result_set = false
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



5
6
7
# File 'lib/mock_redis/future.rb', line 5

def block
  @block
end

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/mock_redis/future.rb', line 5

def command
  @command
end

Instance Method Details

#store_result(result) ⇒ Object



18
19
20
21
# File 'lib/mock_redis/future.rb', line 18

def store_result(result)
  @result_set = true
  @result = @block ? @block.call(result) : result
end

#valueObject

Raises:



13
14
15
16
# File 'lib/mock_redis/future.rb', line 13

def value
  raise FutureNotReady unless @result_set
  @result
end