Sha256: d35890baf0c1d51a4a1949a0f0e25bed04ad9ba4c82953360b7cff716e861f08

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

# frozen_string_literal: true

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

  private

  def init_rails!
    return unless defined?(Rails) && Memolog.config.initializers.include?(:rails)
    return if defined?(Sidekiq) && Sidekiq.server?

    Rails.application.middleware.insert_before(0, Memolog::Middleware)
  end

  def init_sentry!
    return unless defined?(Sentry::Scope) && Memolog.config.initializers.include?(:sentry)
    Sentry::Scope.prepend(Memolog::SentryScopeExtension)
  end

  def init_sidekiq!
    return unless defined?(Sidekiq) && Memolog.config.initializers.include?(:sidekiq)

    Sidekiq.configure_server do |config|
      config.server_middleware do |chain|
        chain.prepend(Memolog::SentrySidekiqMiddleware)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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