Sha256: d6b512f00c78c40d59859d57b18460e69479c3cab51911980f17185ecf17ecd1

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 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::Middleware)
  end

  def init_sentry!
    return unless Memolog.config.initializers.include?(:sentry)
    return unless Object.const_defined?("Sentry::Scope")

    Sentry::Scope.prepend(Memolog::SentryScopeExtension)
  end

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

    Sentry::Sidekiq::SentryContextServerMiddleware.prepend(
      Memolog::SentrySidekiqMiddlewareExtension,
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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