Module: Memolog::Init

Extended by:
Init
Included in:
Init
Defined in:
lib/memolog/init.rb

Instance Method Summary collapse

Instance Method Details

#init_middlewares!Object



6
7
8
9
10
# File 'lib/memolog/init.rb', line 6

def init_middlewares!
  init_rails_middleware!
  init_sidekiq_middleware!
  init_sentry!
end

#init_rails_middleware!Object



12
13
14
15
16
17
18
# File 'lib/memolog/init.rb', line 12

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

#init_sentry!Object



31
32
33
34
35
# File 'lib/memolog/init.rb', line 31

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

  Sentry.prepend(Memolog::SentryExtension)
end

#init_sidekiq_middleware!Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/memolog/init.rb', line 20

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