Class: Procrastinate::Task::Callable
- Inherits:
-
Object
- Object
- Procrastinate::Task::Callable
- Defined in:
- lib/procrastinate/task/callable.rb
Overview
A task that calls the block and returns the result of execution.
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(block) ⇒ Callable
constructor
A new instance of Callable.
-
#run(endpoint) ⇒ Object
Runs this task.
Constructor Details
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
8 9 10 |
# File 'lib/procrastinate/task/callable.rb', line 8 def block @block end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
9 10 11 |
# File 'lib/procrastinate/task/callable.rb', line 9 def result @result end |
Instance Method Details
#run(endpoint) ⇒ Object
Runs this task. Gets passed an endpoint that can be used to communicate values back to the master. Every time you write a value to that endpoint (using #send), the server will call #incoming_message on the task object in the master process. This allows return values and other communication from children to the master (and to the caller in this case).
22 23 24 25 |
# File 'lib/procrastinate/task/callable.rb', line 22 def run(endpoint) r = @b.call endpoint.call(r) if endpoint end |