Class: ActiveRecordQueryCounter::Counter
- Inherits:
-
Object
- Object
- ActiveRecordQueryCounter::Counter
- Defined in:
- lib/active_record_query_counter.rb
Instance Attribute Summary collapse
-
#query_count ⇒ Object
Returns the value of attribute query_count.
-
#query_time ⇒ Object
Returns the value of attribute query_time.
-
#row_count ⇒ Object
Returns the value of attribute row_count.
-
#transactions ⇒ Object
readonly
Returns the value of attribute transactions.
Instance Method Summary collapse
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #transaction_count ⇒ Object
- #transaction_time ⇒ Object
Constructor Details
#initialize ⇒ Counter
Returns a new instance of Counter.
17 18 19 20 21 22 |
# File 'lib/active_record_query_counter.rb', line 17 def initialize @query_count = 0 @row_count = 0 @query_time = 0.0 @transactions = {} end |
Instance Attribute Details
#query_count ⇒ Object
Returns the value of attribute query_count.
14 15 16 |
# File 'lib/active_record_query_counter.rb', line 14 def query_count @query_count end |
#query_time ⇒ Object
Returns the value of attribute query_time.
14 15 16 |
# File 'lib/active_record_query_counter.rb', line 14 def query_time @query_time end |
#row_count ⇒ Object
Returns the value of attribute row_count.
14 15 16 |
# File 'lib/active_record_query_counter.rb', line 14 def row_count @row_count end |
#transactions ⇒ Object (readonly)
Returns the value of attribute transactions.
15 16 17 |
# File 'lib/active_record_query_counter.rb', line 15 def transactions @transactions end |
Instance Method Details
#transaction_count ⇒ Object
24 25 26 |
# File 'lib/active_record_query_counter.rb', line 24 def transaction_count @transactions.size end |
#transaction_time ⇒ Object
28 29 30 |
# File 'lib/active_record_query_counter.rb', line 28 def transaction_time @transactions.values.sum { |count, time| time } end |