Sha256: 27dce9d634697f2665e183b59d5489e28ade8b4fd7ed1a463289a766540e3a79

Contents?: true

Size: 699 Bytes

Versions: 1

Compression:

Stored size: 699 Bytes

Contents

require 'sql_tracker/config'
require 'sql_tracker/handler'
require 'sql_tracker/report'

module SqlTracker
  def self.initialize!
    raise 'sql tracker initialized twice' if @already_initialized

    config = SqlTracker::Config.apply_defaults
    handler = SqlTracker::Handler.new(config)
    handler.subscribe
    @already_initialized = true

    at_exit { handler.save }
  end

  def self.track
    config = SqlTracker::Config.apply_defaults.new
    config.enabled = true
    handler = SqlTracker::Handler.new(config)
    handler.subscribe
    yield
    handler.unsubscribe
    handler.data
  end
end

if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i >= 3
  require 'sql_tracker/railtie'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sql_tracker-1.3.2 lib/sql_tracker.rb