Class: Workerholic::JobWrapper
- Inherits:
-
Object
- Object
- Workerholic::JobWrapper
- Defined in:
- lib/workerholic/job_wrapper.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#execute_at ⇒ Object
Returns the value of attribute execute_at.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#retry_count ⇒ Object
Returns the value of attribute retry_count.
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(options = {}) ⇒ JobWrapper
constructor
A new instance of JobWrapper.
- #perform ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ JobWrapper
Returns a new instance of JobWrapper.
6 7 8 9 10 11 12 13 14 |
# File 'lib/workerholic/job_wrapper.rb', line 6 def initialize(={}) @klass = [:klass] @wrapper = [:wrapper] @arguments = [:arguments] @queue = [:queue] @execute_at = [:execute_at] @retry_count = [:retry_count] || 0 @statistics = JobStatistics.new([:statistics] || {}) end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
4 5 6 |
# File 'lib/workerholic/job_wrapper.rb', line 4 def arguments @arguments end |
#execute_at ⇒ Object
Returns the value of attribute execute_at.
3 4 5 |
# File 'lib/workerholic/job_wrapper.rb', line 3 def execute_at @execute_at end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/workerholic/job_wrapper.rb', line 4 def klass @klass end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
4 5 6 |
# File 'lib/workerholic/job_wrapper.rb', line 4 def queue @queue end |
#retry_count ⇒ Object
Returns the value of attribute retry_count.
3 4 5 |
# File 'lib/workerholic/job_wrapper.rb', line 3 def retry_count @retry_count end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
4 5 6 |
# File 'lib/workerholic/job_wrapper.rb', line 4 def statistics @statistics end |
#wrapper ⇒ Object (readonly)
Returns the value of attribute wrapper.
4 5 6 |
# File 'lib/workerholic/job_wrapper.rb', line 4 def wrapper @wrapper end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 |
# File 'lib/workerholic/job_wrapper.rb', line 39 def ==(other) to_hash == other.to_hash end |
#perform ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/workerholic/job_wrapper.rb', line 28 def perform if wrapper && wrapper.name == 'ActiveJob::QueueAdapters::WorkerholicAdapter::JobWrapper' wrapper.new.perform( 'job_class' => klass, 'arguments' => arguments ) else klass.new.perform(*arguments) end end |
#to_hash ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/workerholic/job_wrapper.rb', line 16 def to_hash { klass: klass, wrapper: wrapper, arguments: arguments, queue: queue, retry_count: retry_count, execute_at: execute_at, statistics: statistics.to_hash } end |