Class: ActiveJob::JobProxy
- Inherits:
-
Base
- Object
- Base
- ActiveJob::JobProxy
- Defined in:
- lib/active_job/job_proxy.rb
Overview
A proxy for managing jobs without having to load the corresponding job class.
This is useful for managing jobs without having the job classes present in the code base.
Defined Under Namespace
Classes: UnsupportedError
Instance Attribute Summary collapse
-
#filtered_raw_data ⇒ Object
Raw data with the sensitive user data filtered out.
-
#job_class_name ⇒ Object
readonly
Returns the value of attribute job_class_name.
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(job_data) ⇒ JobProxy
constructor
A new instance of JobProxy.
- #perform_now ⇒ Object
- #serialize ⇒ Object
Constructor Details
#initialize(job_data) ⇒ JobProxy
Returns a new instance of JobProxy.
13 14 15 16 17 |
# File 'lib/active_job/job_proxy.rb', line 13 def initialize(job_data) super @job_class_name = job_data["job_class"] deserialize(job_data) end |
Instance Attribute Details
#filtered_raw_data ⇒ Object
Raw data with the sensitive user data filtered out.
11 12 13 |
# File 'lib/active_job/job_proxy.rb', line 11 def filtered_raw_data @filtered_raw_data end |
#job_class_name ⇒ Object (readonly)
Returns the value of attribute job_class_name.
9 10 11 |
# File 'lib/active_job/job_proxy.rb', line 9 def job_class_name @job_class_name end |
Instance Method Details
#duration ⇒ Object
29 30 31 32 |
# File 'lib/active_job/job_proxy.rb', line 29 def duration ended_at = finished_at || failed_at ended_at - scheduled_at if ended_at && scheduled_at end |
#perform_now ⇒ Object
25 26 27 |
# File 'lib/active_job/job_proxy.rb', line 25 def perform_now raise UnsupportedError, "A JobProxy doesn't support immediate execution, only enqueuing." end |
#serialize ⇒ Object
19 20 21 22 23 |
# File 'lib/active_job/job_proxy.rb', line 19 def serialize super.tap do |json| json["job_class"] = @job_class_name end end |