Class: Sidekiq::Work
- Inherits:
-
Object
- Object
- Sidekiq::Work
- Defined in:
- lib/sidekiq/api.rb
Overview
Sidekiq::Work represents a job which is currently executing.
Instance Attribute Summary collapse
-
#process_id ⇒ Object
readonly
Returns the value of attribute process_id.
-
#thread_id ⇒ Object
readonly
Returns the value of attribute thread_id.
Instance Method Summary collapse
-
#[](key) ⇒ Object
deprecated.
-
#initialize(pid, tid, hsh) ⇒ Work
constructor
A new instance of Work.
- #job ⇒ Object
- #method_missing(*all) ⇒ Object
- #payload ⇒ Object
- #queue ⇒ Object
- #respond_to_missing?(name, *args) ⇒ Boolean
- #run_at ⇒ Object
Constructor Details
#initialize(pid, tid, hsh) ⇒ Work
Returns a new instance of Work.
1189 1190 1191 1192 1193 1194 |
# File 'lib/sidekiq/api.rb', line 1189 def initialize(pid, tid, hsh) @process_id = pid @thread_id = tid @hsh = hsh @job = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*all) ⇒ Object
1227 1228 1229 |
# File 'lib/sidekiq/api.rb', line 1227 def method_missing(*all) @hsh.send(*all) end |
Instance Attribute Details
#process_id ⇒ Object (readonly)
Returns the value of attribute process_id.
1186 1187 1188 |
# File 'lib/sidekiq/api.rb', line 1186 def process_id @process_id end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
1187 1188 1189 |
# File 'lib/sidekiq/api.rb', line 1187 def thread_id @thread_id end |
Instance Method Details
#[](key) ⇒ Object
deprecated
1213 1214 1215 1216 1217 1218 1219 |
# File 'lib/sidekiq/api.rb', line 1213 def [](key) kwargs = {uplevel: 1} kwargs[:category] = :deprecated if RUBY_VERSION > "3.0" # TODO warn("Direct access to `Sidekiq::Work` attributes is deprecated, please use `#payload`, `#queue`, `#run_at` or `#job` instead", **kwargs) @hsh[key] end |
#job ⇒ Object
1204 1205 1206 |
# File 'lib/sidekiq/api.rb', line 1204 def job @job ||= Sidekiq::JobRecord.new(@hsh["payload"]) end |
#payload ⇒ Object
1208 1209 1210 |
# File 'lib/sidekiq/api.rb', line 1208 def payload @hsh["payload"] end |
#queue ⇒ Object
1196 1197 1198 |
# File 'lib/sidekiq/api.rb', line 1196 def queue @hsh["queue"] end |
#respond_to_missing?(name, *args) ⇒ Boolean
1231 1232 1233 |
# File 'lib/sidekiq/api.rb', line 1231 def respond_to_missing?(name, *args) @hsh.respond_to?(name) end |
#run_at ⇒ Object
1200 1201 1202 |
# File 'lib/sidekiq/api.rb', line 1200 def run_at Time.at(@hsh["run_at"]) end |