krisleech/wisper-sidekiq

View on GitHub
lib/wisper/sidekiq/publisher_extensions.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Wisper
  module Sidekiq
    module PublisherExtensions
      # Extension to automatically register subscriber classes as safe
      module SubscribeRegisterTypes
        def subscribe(listener, *args, **kargs, &block)
          Wisper::Sidekiq::Config.register_safe_types(listener)
          super
        end
      end
    end
  end

  class << self
    # Inject into Wisper.subscribe
    prepend Sidekiq::PublisherExtensions::SubscribeRegisterTypes
  end

  module Publisher
    # Inject into CustomPublisher.new.subscribe
    prepend Sidekiq::PublisherExtensions::SubscribeRegisterTypes

    module ClassMethods
      # Inject into CustomPublisher.subscribe
      prepend Sidekiq::PublisherExtensions::SubscribeRegisterTypes
    end
  end
end