Sha256: 559f953bed20d0f7f0da80cbba691fb76810432f1a7d832f275061e9d69fa371

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

module ARQLogger
  module Initializer
    def self.patch
      class_eval <<-EOS
        class ActiveRecord::LogSubscriber
          alias_method :real_sql, :sql

          def sql(event)
            ARQLogger.pass(event)
            real_sql(event)
          end
        end

        class ActiveRecord::Base
          after_initialize ->{ ARQLogger.instantiate }
        end
      EOS
    end
  end
end

if defined?(ActiveRecord::LogSubscriber)
  ARQLogger::Initializer.patch
elsif defined?(::Rails::Railtie)
  class ARQLoggerApplicationProxy < ::Rails::Railtie
    initializer('add pass method') { ARQLogger::Initializer.patch }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
a_r_q_logger-0.0.8 lib/a_r_q_logger/initializer.rb