Class: ActiveRecord::Assertions::QueryAssertions::SQLCounter
- Inherits:
-
Object
- Object
- ActiveRecord::Assertions::QueryAssertions::SQLCounter
- Defined in:
- lib/active_record/testing/query_assertions.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#log_all ⇒ Object
readonly
Returns the value of attribute log_all.
-
#log_full ⇒ Object
readonly
Returns the value of attribute log_full.
Instance Method Summary collapse
- #call(payload) ⇒ Object
-
#initialize ⇒ SQLCounter
constructor
A new instance of SQLCounter.
- #log ⇒ Object
Constructor Details
#initialize ⇒ SQLCounter
100 101 102 103 |
# File 'lib/active_record/testing/query_assertions.rb', line 100 def initialize @log_full = [] @log_all = [] end |
Instance Attribute Details
#log_all ⇒ Object (readonly)
Returns the value of attribute log_all.
98 99 100 |
# File 'lib/active_record/testing/query_assertions.rb', line 98 def log_all @log_all end |
#log_full ⇒ Object (readonly)
Returns the value of attribute log_full.
98 99 100 |
# File 'lib/active_record/testing/query_assertions.rb', line 98 def log_full @log_full end |
Instance Method Details
#call(payload) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/active_record/testing/query_assertions.rb', line 109 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 ⇒ Object
105 106 107 |
# File 'lib/active_record/testing/query_assertions.rb', line 105 def log @log_full.map(&:first) end |