Module: PredictiveLoad::ActiveRecordCollectionObservation::UnscopedTracker

Defined in:
lib/predictive_load/active_record_collection_observation.rb

Overview

disable eager loading since includes + unscoped is broken on rails 4

Instance Method Summary collapse

Instance Method Details

#predictive_load_disabledObject



42
43
44
# File 'lib/predictive_load/active_record_collection_observation.rb', line 42

def predictive_load_disabled
  Thread.current[:predictive_load_disabled] ||= []
end

#unscopedObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/predictive_load/active_record_collection_observation.rb', line 29

def unscoped
  if block_given?
    begin
      predictive_load_disabled << self
      super
    ensure
      predictive_load_disabled.pop
    end
  else
    super
  end
end