Module: Scrooge::Optimizations::Associations::SingletonMethods
- Defined in:
- lib/optimizations/associations/macro.rb
Constant Summary collapse
- @@preloadable_associations =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #preload_scrooge_associations(result_set, callsite_sig) ⇒ Object
-
#preloadable_associations ⇒ Object
Let’s not preload polymorphic associations or collections.
- #scrooge_preloading_exclude ⇒ Object
Class Method Details
.extended(base) ⇒ Object
31 32 33 34 |
# File 'lib/optimizations/associations/macro.rb', line 31 def self.extended( base ) eigen = class << base; self; end # not used at present end |
Instance Method Details
#preload_scrooge_associations(result_set, callsite_sig) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/optimizations/associations/macro.rb', line 36 def preload_scrooge_associations(result_set, callsite_sig) scrooge_preloading_exclude do callsite_associations = scrooge_callsite(callsite_sig).associations.to_a preload_associations(result_set, callsite_associations) unless callsite_associations.empty? end end |
#preloadable_associations ⇒ Object
Let’s not preload polymorphic associations or collections
53 54 55 56 |
# File 'lib/optimizations/associations/macro.rb', line 53 def preloadable_associations @@preloadable_associations[self.name] ||= reflect_on_all_associations.reject{|a| a.[:polymorphic] || a.macro == :has_many}.map(&:name) end |
#scrooge_preloading_exclude ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/optimizations/associations/macro.rb', line 43 def scrooge_preloading_exclude unless Thread.current[:scrooge_preloading] Thread.current[:scrooge_preloading] = true yield Thread.current[:scrooge_preloading] = false end end |