Class: SidekiqUniqueJobs::Reflections
- Inherits:
-
Object
- Object
- SidekiqUniqueJobs::Reflections
- Defined in:
- lib/sidekiq_unique_jobs/reflections.rb
Overview
Class NotificationCollection provides a collection with known notifications
Constant Summary collapse
- REFLECTIONS =
Returns list of notifications.
[ :after_unlock_callback_failed, :debug, :duplicate, :error, :execution_failed, :lock_failed, :locked, :reschedule_failed, :rescheduled, :timeout, :unknown_sidekiq_worker, :unlock_failed, :unlocked, ].freeze
- DEPRECATIONS =
Returns a hash with deprecated notifications.
{}.freeze
Instance Method Summary collapse
- #configured?(reflection) ⇒ Boolean
-
#dispatch(reflection, *args) ⇒ void
Dispatch a reflected event.
-
#initialize ⇒ Reflections
constructor
A new instance of Reflections.
- #misconfigured?(reflection) ⇒ Boolean
Constructor Details
#initialize ⇒ Reflections
Returns a new instance of Reflections.
41 42 43 |
# File 'lib/sidekiq_unique_jobs/reflections.rb', line 41 def initialize @reflections = {} end |
Instance Method Details
#configured?(reflection) ⇒ Boolean
71 72 73 |
# File 'lib/sidekiq_unique_jobs/reflections.rb', line 71 def configured?(reflection) REFLECTIONS.include?(reflection) end |
#dispatch(reflection, *args) ⇒ void
This method returns an undefined value.
Dispatch a reflected event
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/sidekiq_unique_jobs/reflections.rb', line 53 def dispatch(reflection, *args) # rubocop:disable Metrics/MethodLength if (block = @reflections[reflection]) block.call(*args) if DEPRECATIONS.key?(reflection) replacement, removal_version = DEPRECATIONS[reflection] SidekiqUniqueJobs::Deprecation.warn( "#{reflection} is deprecated and will be removed in version #{removal_version}." \ " Use #{replacement} instead.", ) end elsif misconfigured?(reflection) raise NoSuchNotificationError, reflection end nil end |
#misconfigured?(reflection) ⇒ Boolean
75 76 77 |
# File 'lib/sidekiq_unique_jobs/reflections.rb', line 75 def misconfigured?(reflection) !configured?(reflection) end |