Module: PredictiveLoad::ActiveRecordCollectionObservation::Rails5RelationObservation

Defined in:
lib/predictive_load/active_record_collection_observation.rb

Instance Method Summary collapse

Instance Method Details

#recordsObject

this essentially intercepts the enumerable methods that would result in n+1s since most of those are delegated to :records in Rails 5+ in the ActiveRecord::Relation::Delegation module



19
20
21
22
23
24
25
# File 'lib/predictive_load/active_record_collection_observation.rb', line 19

def records
  record_array = super
  if record_array.size > 1 && collection_observer
    collection_observer.observe(record_array.dup)
  end
  record_array
end