Class: ActiveRecordQueryCount::Compare::Comparator
- Inherits:
-
Object
- Object
- ActiveRecordQueryCount::Compare::Comparator
- Defined in:
- lib/active_record_query_count/compare/comparator.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
Returns the value of attribute results.
-
#scripts_loaded ⇒ Object
Returns the value of attribute scripts_loaded.
Instance Method Summary collapse
- #code(name) ⇒ Object
- #compare! ⇒ Object
-
#initialize ⇒ Comparator
constructor
A new instance of Comparator.
Constructor Details
#initialize ⇒ Comparator
Returns a new instance of Comparator.
6 7 8 9 |
# File 'lib/active_record_query_count/compare/comparator.rb', line 6 def initialize @results = {} @scripts_loaded = 0 end |
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
4 5 6 |
# File 'lib/active_record_query_count/compare/comparator.rb', line 4 def results @results end |
#scripts_loaded ⇒ Object
Returns the value of attribute scripts_loaded.
4 5 6 |
# File 'lib/active_record_query_count/compare/comparator.rb', line 4 def scripts_loaded @scripts_loaded end |
Instance Method Details
#code(name) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/active_record_query_count/compare/comparator.rb', line 11 def code(name) @scripts_loaded += 1 ActiveRecordQueryCount.start_with_block(printer: :none) do yield @results[name] = ActiveRecordQueryCount.tracker.active_record_query_tracker.dup end end |
#compare! ⇒ Object
20 21 22 23 24 25 |
# File 'lib/active_record_query_count/compare/comparator.rb', line 20 def compare! raise 'Exactly two code blocks are required' if @scripts_loaded != 2 ActiveRecordQueryCount::Printer::HtmlCompare.new(data_1: results.slice(results.keys[0]), data_2: results.slice(results.keys[1])).print end |