Sha256: 02d79a0d55b080445f19a271f2102603b15c702bfdcc9e4f7470782e32752ed7

Contents?: true

Size: 799 Bytes

Versions: 6

Compression:

Stored size: 799 Bytes

Contents

module Timber
  module Integrations
    module ActiveRecord
      # Reponsible for uninstalling the default `ActiveRecord::LogSubscriber` and replacing it
      # with the `TimberLogSubscriber`.
      #
      # @private
      class LogSubscriber < Integrator
        def initialize
          require "timber/integrations/active_record/log_subscriber/timber_log_subscriber"
        rescue LoadError => e
          raise RequirementNotMetError.new(e.message)
        end

        def integrate!
          return true if Util::ActiveSupportLogSubscriber.subscribed?(:active_record, TimberLogSubscriber)

          Util::ActiveSupportLogSubscriber.unsubscribe!(:active_record, ::ActiveRecord::LogSubscriber)
          TimberLogSubscriber.attach_to(:active_record)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
timber-2.0.24 lib/timber/integrations/active_record/log_subscriber.rb
timber-2.0.23 lib/timber/integrations/active_record/log_subscriber.rb
timber-2.0.22 lib/timber/integrations/active_record/log_subscriber.rb
timber-2.0.21 lib/timber/integrations/active_record/log_subscriber.rb
timber-2.0.20 lib/timber/integrations/active_record/log_subscriber.rb
timber-2.0.19 lib/timber/integrations/active_record/log_subscriber.rb