Class: Boogaloo::WorkerThread
- Inherits:
-
Thread
- Object
- Thread
- Boogaloo::WorkerThread
- Defined in:
- lib/boogaloo/worker_thread.rb
Overview
Handles method calls to a service instance in a thread.
Instance Method Summary collapse
-
#initialize ⇒ WorkerThread
constructor
Initialize a new WorkerThread instance.
-
#perform(meth, *a, &b) ⇒ Object
Perform method calls on the service instance.
-
#use_instance(obj) ⇒ Object
Tells the WorkerThread to forward method calls to the given service instance.
Constructor Details
#initialize ⇒ WorkerThread
Initialize a new WorkerThread instance.
7 8 9 10 11 12 |
# File 'lib/boogaloo/worker_thread.rb', line 7 def initialize super {} @obj = nil end |
Instance Method Details
#perform(meth, *a, &b) ⇒ Object
Perform method calls on the service instance.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/boogaloo/worker_thread.rb', line 26 def perform(meth, *a, &b) ret = nil begin ret = @obj.send(meth, *a) rescue NoMethodError, TypeError => e return e end ret end |
#use_instance(obj) ⇒ Object
Tells the WorkerThread to forward method calls to the given service instance.
Parameters:
objThe service instance to forward to.
19 20 21 22 23 |
# File 'lib/boogaloo/worker_thread.rb', line 19 def use_instance(obj) @obj = obj end |