Class: ActiveRecord::Assertions::QueryAssertions::SQLCounter
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/lib/active_record/testing/query_assertions.rb |
Class Method Summary
- .new ⇒ SQLCounter constructor
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new ⇒ SQLCounter
# File 'activerecord/lib/active_record/testing/query_assertions.rb', line 94
def initialize @log_full = [] @log_all = [] end
Instance Attribute Details
#log_all (readonly)
[ GitHub ]# File 'activerecord/lib/active_record/testing/query_assertions.rb', line 92
attr_reader :log_full, :log_all
#log_full (readonly)
[ GitHub ]# File 'activerecord/lib/active_record/testing/query_assertions.rb', line 92
attr_reader :log_full, :log_all
Instance Method Details
#call(payload)
[ GitHub ]# File 'activerecord/lib/active_record/testing/query_assertions.rb', line 103
def call(*, payload) return if payload[:cached] sql = payload[:sql] @log_all << sql unless payload[:name] == "SCHEMA" bound_values = (payload[:binds] || []).map do |value| value = value.value_for_database if value.respond_to?(:value_for_database) value end @log_full << [sql, bound_values] end end
#log
[ GitHub ]# File 'activerecord/lib/active_record/testing/query_assertions.rb', line 99
def log @log_full.map(&:first) end