Class: Conflow::Future
- Inherits:
-
Object
- Object
- Conflow::Future
- Defined in:
- lib/conflow/future.rb
Overview
Struct like objects that represent value to be returned by Job
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Job which result is promised.
-
#result_key ⇒ Object
readonly
Key in the result hash to which this future proxies.
Instance Method Summary collapse
-
#[](key) ⇒ Future
Returns new Future with assigned key, if possible.
-
#build_promise(depending_job, param_key) ⇒ Conflow::Promise
private
Builds promise from this future.
-
#initialize(job, result_key = nil) ⇒ Future
constructor
private
A new instance of Future.
Constructor Details
#initialize(job, result_key = nil) ⇒ Future
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Future.
25 26 27 28 |
# File 'lib/conflow/future.rb', line 25 def initialize(job, result_key = nil) @job = job @result_key = result_key end |
Instance Attribute Details
#job ⇒ Object (readonly)
Job which result is promised
17 18 19 |
# File 'lib/conflow/future.rb', line 17 def job @job end |
#result_key ⇒ Object (readonly)
Key in the result hash to which this future proxies
19 20 21 |
# File 'lib/conflow/future.rb', line 19 def result_key @result_key end |
Instance Method Details
#[](key) ⇒ Future
Returns new Conflow::Future with assigned key, if possible
36 37 38 39 |
# File 'lib/conflow/future.rb', line 36 def [](key) raise InvalidNestedFuture if result_key Future.new(job, key) end |
#build_promise(depending_job, param_key) ⇒ Conflow::Promise
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds promise from this future
46 47 48 49 50 51 |
# File 'lib/conflow/future.rb', line 46 def build_promise(depending_job, param_key) Promise.new.tap do |promise| promise.assign_attributes(job_id: job.id, hash_field: param_key, result_key: result_key) depending_job.promise_ids << promise.id end end |