Class: ResqueAsync::Enqueuers::ClassEnqueuer
- Inherits:
-
Object
- Object
- ResqueAsync::Enqueuers::ClassEnqueuer
- Defined in:
- lib/resque-async/enqueuers.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#host_class ⇒ Object
readonly
Returns the value of attribute host_class.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
-
#initialize(host_class, priority) ⇒ ClassEnqueuer
constructor
A new instance of ClassEnqueuer.
- #method_missing(methId, *args) ⇒ Object
Constructor Details
#initialize(host_class, priority) ⇒ ClassEnqueuer
Returns a new instance of ClassEnqueuer.
8 9 10 11 |
# File 'lib/resque-async/enqueuers.rb', line 8 def initialize(host_class, priority) @host_class = host_class @priority = priority end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methId, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/resque-async/enqueuers.rb', line 13 def method_missing(methId, *args) # call super unless the host responds to the method return super unless @host_class.respond_to?(methId.id2name.to_sym) case @priority when Class worker = @priority when :high worker = Workers::HighPriorityClassMethod when :medium worker = Workers::MediumPriorityClassMethod when :low worker = Workers::LowPriorityClassMethod else raise StandardError('Unknown priority') end # enqueue Resque.enqueue(worker, @host_class.name, methId.id2name, args) end |
Instance Attribute Details
#host_class ⇒ Object (readonly)
Returns the value of attribute host_class.
7 8 9 |
# File 'lib/resque-async/enqueuers.rb', line 7 def host_class @host_class end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
7 8 9 |
# File 'lib/resque-async/enqueuers.rb', line 7 def priority @priority end |