Module: PredictiveLoad::ActiveRecordCollectionObservation

Defined in:
lib/predictive_load/active_record_collection_observation.rb

Defined Under Namespace

Modules: AssociationNotification, CollectionAssociationNotification, CollectionMember, Rails4RelationObservation, Rails5RelationObservation, UnscopedTracker

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/predictive_load/active_record_collection_observation.rb', line 3

def self.included(base)
  ActiveRecord::Relation.class_attribute :collection_observer
  if ActiveRecord::VERSION::MAJOR >= 5
    ActiveRecord::Relation.prepend Rails5RelationObservation
  else
    ActiveRecord::Relation.prepend Rails4RelationObservation
  end
  ActiveRecord::Base.include CollectionMember
  ActiveRecord::Base.extend UnscopedTracker
  ActiveRecord::Associations::Association.include AssociationNotification
  ActiveRecord::Associations::CollectionAssociation.include CollectionAssociationNotification
end