Sha256: 171bbb3f7b649acaf3d0b5eea1c8f068e213a1f0423c8ffc84febbfdcc497b42

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

# frozen_string_literal: true

module Memolog::Init
  extend self

  def init_middlewares!
    init_rails_middleware!
    init_sidekiq_middleware!
  end

  def init_rails_middleware!
    return unless Memolog.config.middlewares.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.middlewares.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

1 entries across 1 versions & 1 rubygems

Version Path
memolog-0.3.4 lib/memolog/init.rb