Class: ActiveRecord::QueryCounter
- Inherits:
-
Object
- Object
- ActiveRecord::QueryCounter
- Defined in:
- lib/rspec/dunlop/matchers/exceed_query_limit.rb
Instance Attribute Summary collapse
-
#performed_queries ⇒ Object
readonly
Returns the value of attribute performed_queries.
-
#query_count ⇒ Object
readonly
Returns the value of attribute query_count.
Instance Method Summary collapse
- #callback(name, start, finish, message_id, values) ⇒ Object
-
#initialize ⇒ QueryCounter
constructor
A new instance of QueryCounter.
- #to_proc ⇒ Object
Constructor Details
#initialize ⇒ QueryCounter
Returns a new instance of QueryCounter.
7 8 9 10 |
# File 'lib/rspec/dunlop/matchers/exceed_query_limit.rb', line 7 def initialize @performed_queries = [] @query_count = 0 end |
Instance Attribute Details
#performed_queries ⇒ Object (readonly)
Returns the value of attribute performed_queries.
5 6 7 |
# File 'lib/rspec/dunlop/matchers/exceed_query_limit.rb', line 5 def performed_queries @performed_queries end |
#query_count ⇒ Object (readonly)
Returns the value of attribute query_count.
5 6 7 |
# File 'lib/rspec/dunlop/matchers/exceed_query_limit.rb', line 5 def query_count @query_count end |
Instance Method Details
#callback(name, start, finish, message_id, values) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rspec/dunlop/matchers/exceed_query_limit.rb', line 16 def callback(name, start, finish, , values) unless %w[ CACHE SCHEMA SAVEPOINT ].include?(values[:name]) @query_count += 1 @performed_queries << values[:sql] end end |
#to_proc ⇒ Object
12 13 14 |
# File 'lib/rspec/dunlop/matchers/exceed_query_limit.rb', line 12 def to_proc lambda(&method(:callback)) end |