Module: SqlTracker

Defined in:
lib/sql_tracker.rb,
lib/sql_tracker/config.rb,
lib/sql_tracker/report.rb,
lib/sql_tracker/handler.rb,
lib/sql_tracker/railtie.rb,
lib/sql_tracker/version.rb,
lib/sql_tracker/terminal.rb

Defined Under Namespace

Classes: Config, Handler, Railtie, Report, Terminal

Constant Summary collapse

VERSION =
'1.3.2'.freeze

Class Method Summary collapse

Class Method Details

.initialize!Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/sql_tracker.rb', line 6

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

.trackObject



17
18
19
20
21
22
23
24
25
# File 'lib/sql_tracker.rb', line 17

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