Class: ActiveRecord::Assertions::QueryAssertions::SQLCounter
- Defined in:
- activerecord/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
Returns a new instance of SQLCounter.
| 94 95 96 97 | # File 'activerecord/lib/active_record/testing/query_assertions.rb', line 94 def initialize @log_full = [] @log_all = [] end | 
Instance Attribute Details
#log_all ⇒ Object (readonly)
Returns the value of attribute log_all.
| 92 93 94 | # File 'activerecord/lib/active_record/testing/query_assertions.rb', line 92 def log_all @log_all end | 
#log_full ⇒ Object (readonly)
Returns the value of attribute log_full.
| 92 93 94 | # File 'activerecord/lib/active_record/testing/query_assertions.rb', line 92 def log_full @log_full end | 
Instance Method Details
#call(payload) ⇒ Object
| 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | # 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 ⇒ Object
| 99 100 101 | # File 'activerecord/lib/active_record/testing/query_assertions.rb', line 99 def log @log_full.map(&:first) end |