Sha256: ab981679fe24cd7803f0e6f41ee0668b41f218a81ed51ea44b79b94f5799b836

Contents?: true

Size: 749 Bytes

Versions: 7

Compression:

Stored size: 749 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

7 entries across 7 versions & 1 rubygems

Version Path
memolog-0.4.6 lib/memolog/init.rb
memolog-0.4.5 lib/memolog/init.rb
memolog-0.4.4 lib/memolog/init.rb
memolog-0.4.2 lib/memolog/init.rb
memolog-0.4.1 lib/memolog/init.rb
memolog-0.4.0 lib/memolog/init.rb
memolog-0.3.5 lib/memolog/init.rb