Class: Procrastinate::Task::MethodCall
- Inherits:
-
Object
- Object
- Procrastinate::Task::MethodCall
- Includes:
- Procrastinate::Task
- Defined in:
- lib/procrastinate/task/method_call.rb
Overview
Constructs an object of type klass
and calls a method on it.
Instance Attribute Summary collapse
-
#a ⇒ Object
readonly
Returns the value of attribute a.
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#i ⇒ Object
readonly
Returns the value of attribute i.
-
#m ⇒ Object
readonly
Returns the value of attribute m.
Instance Method Summary collapse
-
#initialize(instance, method, arguments, block) ⇒ MethodCall
constructor
A new instance of MethodCall.
- #result ⇒ Object
-
#run(endpoint) ⇒ Object
Runs this task.
Constructor Details
#initialize(instance, method, arguments, block) ⇒ MethodCall
Returns a new instance of MethodCall.
14 15 16 17 18 19 |
# File 'lib/procrastinate/task/method_call.rb', line 14 def initialize(instance, method, arguments, block) @i = instance @m = method @a = arguments @b = block end |
Instance Attribute Details
#a ⇒ Object (readonly)
Returns the value of attribute a.
11 12 13 |
# File 'lib/procrastinate/task/method_call.rb', line 11 def a @a end |
#b ⇒ Object (readonly)
Returns the value of attribute b.
12 13 14 |
# File 'lib/procrastinate/task/method_call.rb', line 12 def b @b end |
#i ⇒ Object (readonly)
Returns the value of attribute i.
9 10 11 |
# File 'lib/procrastinate/task/method_call.rb', line 9 def i @i end |
#m ⇒ Object (readonly)
Returns the value of attribute m.
10 11 12 |
# File 'lib/procrastinate/task/method_call.rb', line 10 def m @m end |
Instance Method Details
#result ⇒ Object
32 33 34 |
# File 'lib/procrastinate/task/method_call.rb', line 32 def result @result ||= Result.new end |
#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).
27 28 29 30 |
# File 'lib/procrastinate/task/method_call.rb', line 27 def run(endpoint) r = @i.send(@m, *@a, &@b) endpoint.send r if endpoint end |