Sha256: c44382edfc7440cbb869331af8950850493960f0ce87fafc9cb0ab16919e595a

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

class Memolog::Init
  def call
    init_rails_middleware!
    init_sidekiq_middleware!
  end

  private

  def init_rails_middleware!
    return unless Memolog.config.initializers.include?(:rails)
    return unless Object.const_defined?("Rails")
    return if Object.const_defined?("Sidekiq") && Sidekiq.server?

    Rails.application.middleware.insert_before(0, Memolog::RailsMiddleware)
  end

  def init_sidekiq_middleware!
    return unless Memolog.config.initializers.include?(:sidekiq)
    return unless Object.const_defined?("Sidekiq")

    Sidekiq.configure_server do |config|
      config.server_middleware do |chain|
        chain.prepend(Memolog::SidekiqMiddleware)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
memolog-0.3.3 lib/memolog/init.rb
memolog-0.3.2 lib/memolog/init.rb