Module: ActiveRecordQueryCount::Recording::Base

Included in:
ActiveRecordQueryCount
Defined in:
lib/active_record_query_count/recording/base.rb

Instance Method Summary collapse

Instance Method Details

#end_recording(printer: :console) ⇒ Object



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

def end_recording(printer: :console)
  tracker.unsubscribe
  case printer
  when :html
    Printer::Html.new(data: tracker.active_record_query_tracker).print
  when :console
    Printer::Console.new(data: tracker.active_record_query_tracker).print
  end
end

#start_recordingObject



12
13
14
15
# File 'lib/active_record_query_count/recording/base.rb', line 12

def start_recording
  tracker.reset_query_count
  tracker.subscribe
end

#start_with_block(printer: :console) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/active_record_query_count/recording/base.rb', line 4

def start_with_block(printer: :console)
  raise 'Block not given' unless block_given?

  start_recording
  yield
  end_recording(printer: printer)
end