Module: Qe::Worker
- Defined in:
- lib/qe/worker.rb,
lib/qe/worker/class_methods.rb,
lib/qe/worker/instance_methods.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.find(name) ⇒ Object
Find a worker by its name.
- .included(base) ⇒ Object
-
.perform(worker_name, options) ⇒ Object
Perform the specified worker if given options.
Class Method Details
.find(name) ⇒ Object
Find a worker by its name. If worker constant is not found, raises a NameError
exception.
13 14 15 16 17 |
# File 'lib/qe/worker.rb', line 13 def self.find(name) name.split("::").reduce(Object) do |const, name| const.const_get(name) end end |
.included(base) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/qe/worker.rb', line 3 def self.included(base) base.class_eval do include InstanceMethods extend ClassMethods end end |
.perform(worker_name, options) ⇒ Object
Perform the specified worker if given options.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/qe/worker.rb', line 20 def self.perform(worker_name, ) find(worker_name).new().tap do |job| begin job.before job.perform job.after rescue Exception => error job.error(error) end end end |