Class: SqlQueriesCount::QueryCounter
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- SqlQueriesCount::QueryCounter
- Defined in:
- lib/sql_queries_count/query_counter.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ QueryCounter
constructor
A new instance of QueryCounter.
- #sql(event) ⇒ Object
Constructor Details
#initialize ⇒ QueryCounter
Returns a new instance of QueryCounter.
17 18 19 |
# File 'lib/sql_queries_count/query_counter.rb', line 17 def initialize super end |
Class Method Details
.counter ⇒ Object
8 9 10 |
# File 'lib/sql_queries_count/query_counter.rb', line 8 def self.counter Thread.current["active_record_sql_count"] ||= 0 end |
.counter=(value) ⇒ Object
4 5 6 |
# File 'lib/sql_queries_count/query_counter.rb', line 4 def self.counter=(value) Thread.current["active_record_sql_count"] = value end |
.reset_counter ⇒ Object
12 13 14 15 |
# File 'lib/sql_queries_count/query_counter.rb', line 12 def self.reset_counter rt, self.counter = counter, 0 rt end |
Instance Method Details
#sql(event) ⇒ Object
21 22 23 |
# File 'lib/sql_queries_count/query_counter.rb', line 21 def sql(event) self.class.counter += 1 end |