Sha256: 4e56d9e58b724f4391297bbdc6014a18c7f6fe552ab2efa197f8cc55515ca683

Contents?: true

Size: 802 Bytes

Versions: 3

Compression:

Stored size: 802 Bytes

Contents

module RorVsWild
  module Plugin
    class ActiveRecord
      def self.setup
        return if @installed
        setup_callback
        @installed = true
      end

      def self.setup_callback
        return unless defined?(::ActiveSupport::Notifications.subscribe)
        ActiveSupport::Notifications.subscribe("sql.active_record", new)
      end

      IGNORED_QUERIES = %w[EXPLAIN SCHEMA].freeze

      def start(name, id, payload)
        return if IGNORED_QUERIES.include?(payload[:name])
        RorVsWild::Section.start do |section|
          section.command = payload[:sql]
          section.kind = "sql".freeze
        end
      end

      def finish(name, id, payload)
        return if IGNORED_QUERIES.include?(payload[:name])
        RorVsWild::Section.stop
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rorvswild-1.0.0.pre.alpha3 lib/rorvswild/plugin/active_record.rb
rorvswild-1.0.0.pre.alpha2 lib/rorvswild/plugin/active_record.rb
rorvswild-1.0.0.pre.alpha lib/rorvswild/plugin/active_record.rb