Sha256: 6abbd786d90d1ead2363f8e08f6dba3fd89881eb76d43c9695215fbf42672ece

Contents?: true

Size: 887 Bytes

Versions: 10

Compression:

Stored size: 887 Bytes

Contents

# frozen_string_literal: true

module Memolog::Init
  extend self

  def init_middlewares!
    init_rails_middleware!
    init_sidekiq_middleware!
    init_sentry!
  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

  def init_sentry!
    return unless Object.const_defined?(:Sentry)

    Sentry.prepend(Memolog::SentryExtension)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
memolog-0.5.6 lib/memolog/init.rb
memolog-0.5.5 lib/memolog/init.rb
memolog-0.5.4 lib/memolog/init.rb
memolog-0.5.3 lib/memolog/init.rb
memolog-0.5.2 lib/memolog/init.rb
memolog-0.5.1 lib/memolog/init.rb
memolog-0.5.0 lib/memolog/init.rb
memolog-0.4.9 lib/memolog/init.rb
memolog-0.4.8 lib/memolog/init.rb
memolog-0.4.7 lib/memolog/init.rb