Class: ActiveRecord::SQLCounter
- Inherits:
-
Object
- Object
- ActiveRecord::SQLCounter
- Defined in:
- lib/active_record/test_case.rb
Class Attribute Summary collapse
-
.ignored_sql ⇒ Object
Returns the value of attribute ignored_sql.
-
.log ⇒ Object
Returns the value of attribute log.
-
.log_all ⇒ Object
Returns the value of attribute log_all.
Instance Attribute Summary collapse
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
Class Method Summary collapse
Instance Method Summary collapse
- #call(name, start, finish, message_id, values) ⇒ Object
-
#initialize(ignore = Regexp.union(self.class.ignored_sql)) ⇒ SQLCounter
constructor
A new instance of SQLCounter.
Constructor Details
#initialize(ignore = Regexp.union(self.class.ignored_sql)) ⇒ SQLCounter
Returns a new instance of SQLCounter.
106 107 108 |
# File 'lib/active_record/test_case.rb', line 106 def initialize(ignore = Regexp.union(self.class.ignored_sql)) @ignore = ignore end |
Class Attribute Details
.ignored_sql ⇒ Object
Returns the value of attribute ignored_sql.
84 85 86 |
# File 'lib/active_record/test_case.rb', line 84 def ignored_sql @ignored_sql end |
.log ⇒ Object
Returns the value of attribute log.
84 85 86 |
# File 'lib/active_record/test_case.rb', line 84 def log @log end |
.log_all ⇒ Object
Returns the value of attribute log_all.
84 85 86 |
# File 'lib/active_record/test_case.rb', line 84 def log_all @log_all end |
Instance Attribute Details
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
104 105 106 |
# File 'lib/active_record/test_case.rb', line 104 def ignore @ignore end |
Class Method Details
.clear_log ⇒ Object
85 |
# File 'lib/active_record/test_case.rb', line 85 def clear_log; self.log = []; self.log_all = []; end |
Instance Method Details
#call(name, start, finish, message_id, values) ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/active_record/test_case.rb', line 110 def call(name, start, finish, , values) sql = values[:sql] # FIXME: this seems bad. we should probably have a better way to indicate # the query was cached return if 'CACHE' == values[:name] self.class.log_all << sql self.class.log << sql unless ignore =~ sql end |