Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/scrooge.rb
Constant Summary collapse
- ScroogeCallsiteSample =
0..10
- @@scrooge_callsites =
{}
Class Method Summary collapse
-
.find_by_sql(sql) ⇒ Object
Determine if a given SQL string is a candidate for callsite <=> columns optimization.
-
.scrooge_callsite(callsite_signature) ⇒ Object
Fetch or setup a callsite instance for a given signature.
-
.scrooge_callsites ⇒ Object
Expose known callsites for this model.
-
.scrooge_flush_callsites! ⇒ Object
Flush all known callsites.Mostly a test helper.
Class Method Details
.find_by_sql(sql) ⇒ Object
Determine if a given SQL string is a candidate for callsite <=> columns optimization.
22 23 24 25 26 27 28 |
# File 'lib/scrooge.rb', line 22 def find_by_sql(sql) if scope_with_scrooge?(sql) find_by_sql_with_scrooge(sql) else find_by_sql_without_scrooge(sql) end end |
.scrooge_callsite(callsite_signature) ⇒ Object
Fetch or setup a callsite instance for a given signature
38 39 40 41 |
# File 'lib/scrooge.rb', line 38 def scrooge_callsite( callsite_signature ) @@scrooge_callsites[self.table_name] ||= {} @@scrooge_callsites[self.table_name][callsite_signature] ||= callsite( callsite_signature ) end |
.scrooge_callsites ⇒ Object
Expose known callsites for this model
32 33 34 |
# File 'lib/scrooge.rb', line 32 def scrooge_callsites @@scrooge_callsites[self.table_name] ||= {} end |
.scrooge_flush_callsites! ⇒ Object
Flush all known callsites.Mostly a test helper.
45 46 47 |
# File 'lib/scrooge.rb', line 45 def scrooge_flush_callsites! @@scrooge_callsites[self.table_name] = {} end |