Module: Wurk::Job::Options::ClassMethods
- Included in:
- Worker::ClassMethods
- Defined in:
- lib/wurk/job/options.rb
Overview
Also the options half of Worker::ClassMethods, so an ActiveJob class configuring a Wurk option is told about a bad value at the same place a plain worker is.
Instance Attribute Summary collapse
- #sidekiq_options_hash ⇒ Object
-
#sidekiq_retries_exhausted_block ⇒ Object
readonly
Returns the value of attribute sidekiq_retries_exhausted_block.
-
#sidekiq_retry_in_block ⇒ Object
readonly
Returns the value of attribute sidekiq_retry_in_block.
Instance Method Summary collapse
-
#get_sidekiq_options ⇒ Object
Sidekiq's public API name — must stay
get_sidekiq_options. - #inherited(subclass) ⇒ Object
-
#sidekiq_options(opts = {}) ⇒ Hash
Set per-class job options (merged over any inherited options).
- #sidekiq_retries_exhausted(&block) ⇒ Object
- #sidekiq_retry_in(&block) ⇒ Object
Instance Attribute Details
#sidekiq_options_hash ⇒ Object
60 61 62 |
# File 'lib/wurk/job/options.rb', line 60 def end |
#sidekiq_retries_exhausted_block ⇒ Object (readonly)
Returns the value of attribute sidekiq_retries_exhausted_block.
66 67 68 |
# File 'lib/wurk/job/options.rb', line 66 def sidekiq_retries_exhausted_block @sidekiq_retries_exhausted_block end |
#sidekiq_retry_in_block ⇒ Object (readonly)
Returns the value of attribute sidekiq_retry_in_block.
66 67 68 |
# File 'lib/wurk/job/options.rb', line 66 def sidekiq_retry_in_block @sidekiq_retry_in_block end |
Instance Method Details
#get_sidekiq_options ⇒ Object
Sidekiq's public API name — must stay get_sidekiq_options.
56 57 58 |
# File 'lib/wurk/job/options.rb', line 56 def # rubocop:disable Naming/AccessorMethodName @sidekiq_options_hash ||= # rubocop:disable Naming/MemoizedInstanceVariableName end |
#inherited(subclass) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/wurk/job/options.rb', line 76 def inherited(subclass) super subclass.instance_variable_set(:@sidekiq_options_hash, .dup) inherit_ivar(subclass, :@sidekiq_retry_in_block) inherit_ivar(subclass, :@sidekiq_retries_exhausted_block) end |
#sidekiq_options(opts = {}) ⇒ Hash
Set per-class job options (merged over any inherited options).
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/wurk/job/options.rb', line 42 def (opts = {}) stringified = opts.to_h { |key, val| [key.to_s, val.is_a?(::Hash) ? val.transform_keys(&:to_s) : val] } Wurk::JobUtil.validate_track!(stringified['track'], stringified) if stringified.key?('track') Wurk::JobUtil.validate_bounds!(stringified) merged = .merge(stringified) # On the merged options rather than the new ones, and before the # assign: a subclass adding `collapse:` to a parent's `unique_for:` # has declared both, and only the merge can see it. Raising first # leaves the class holding the options it had. Wurk::Collapse.policy_for(merged) @sidekiq_options_hash = merged end |
#sidekiq_retries_exhausted(&block) ⇒ Object
72 73 74 |
# File 'lib/wurk/job/options.rb', line 72 def sidekiq_retries_exhausted(&block) @sidekiq_retries_exhausted_block = block end |
#sidekiq_retry_in(&block) ⇒ Object
68 69 70 |
# File 'lib/wurk/job/options.rb', line 68 def sidekiq_retry_in(&block) @sidekiq_retry_in_block = block end |