Class: MockRedis::Future
- Inherits:
-
Object
- Object
- MockRedis::Future
- Defined in:
- lib/mock_redis/future.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
-
#initialize(command, block = nil) ⇒ Future
constructor
A new instance of Future.
- #store_result(result) ⇒ Object
- #value ⇒ Object
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
#block ⇒ Object (readonly)
Returns the value of attribute block.
5 6 7 |
# File 'lib/mock_redis/future.rb', line 5 def block @block end |
#command ⇒ Object (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 |
#value ⇒ Object
13 14 15 16 |
# File 'lib/mock_redis/future.rb', line 13 def value raise FutureNotReady unless @result_set @result end |