Class: Procrastinate::Task::MethodCall

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#aObject (readonly)

Returns the value of attribute a.



11
12
13
# File 'lib/procrastinate/task/method_call.rb', line 11

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



12
13
14
# File 'lib/procrastinate/task/method_call.rb', line 12

def b
  @b
end

#iObject (readonly)

Returns the value of attribute i.



9
10
11
# File 'lib/procrastinate/task/method_call.rb', line 9

def i
  @i
end

#mObject (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

#resultObject



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