Sha256: 8bfeedbbe2a7007020a67f7f8ac1cdfb2e9b081bde5474a3dfe94eb735129636

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

class Memolog::Init
  def call
    init_rails!
    init_sentry!
    init_sidekiq!
  end

  private

  def init_rails!
    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_sentry!
    return unless Memolog.config.initializers.include?(:sentry)
    return unless Object.const_defined?("Sentry")

    Sentry.prepend(Memolog::SentryExtension)
  end

  def init_sidekiq!
    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

1 entries across 1 versions & 1 rubygems

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