class SidekiqUniqueJobs::Reflections
Class NotificationCollection provides a collection with known notifications
@author Mikael Henriksson <mikael@mhenrixon.com>
Constants
- DEPRECATIONS
@return [Hash<Symbol,
Array
<Symbol, String>>] a hash with deprecated notifications- REFLECTIONS
@return [Array<Symbol>] list of notifications
Public Class Methods
new()
click to toggle source
# File lib/sidekiq_unique_jobs/reflections.rb, line 41 def initialize @reflections = {} end
Public Instance Methods
configured?(reflection)
click to toggle source
# File lib/sidekiq_unique_jobs/reflections.rb, line 71 def configured?(reflection) REFLECTIONS.include?(reflection) end
dispatch(reflection, *args)
click to toggle source
Dispatch a reflected event
@param [reflection] reflection the reflected event @param [Array] args the arguments to provide to the block
@return [void] <description>
# File lib/sidekiq_unique_jobs/reflections.rb, line 53 def dispatch(reflection, *args) 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)
click to toggle source
# File lib/sidekiq_unique_jobs/reflections.rb, line 75 def misconfigured?(reflection) !configured?(reflection) end