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.
79 80 81 |
# File 'lib/active_record/test_case.rb', line 79 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.
57 58 59 |
# File 'lib/active_record/test_case.rb', line 57 def ignored_sql @ignored_sql end |
.log ⇒ Object
Returns the value of attribute log.
57 58 59 |
# File 'lib/active_record/test_case.rb', line 57 def log @log end |
.log_all ⇒ Object
Returns the value of attribute log_all.
57 58 59 |
# File 'lib/active_record/test_case.rb', line 57 def log_all @log_all end |
Instance Attribute Details
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
77 78 79 |
# File 'lib/active_record/test_case.rb', line 77 def ignore @ignore end |
Class Method Details
.clear_log ⇒ Object
58 |
# File 'lib/active_record/test_case.rb', line 58 def clear_log; self.log = []; self.log_all = []; end |
Instance Method Details
#call(name, start, finish, message_id, values) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/active_record/test_case.rb', line 83 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 |