Class: ActiveRecord::Associations::Preloader::Association

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/associations/preloader/association.rb

Overview

:nodoc:

Direct Known Subclasses

CollectionAssociation, SingularAssociation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, owners, reflection, preload_scope) ⇒ Association

Returns a new instance of Association.



10
11
12
13
14
15
16
17
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 10

def initialize(klass, owners, reflection, preload_scope)
  @klass         = klass
  @owners        = owners
  @reflection    = reflection
  @preload_scope = preload_scope
  @model         = owners.first && owners.first.class
  @preloaded_records = []
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



7
8
9
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 7

def klass
  @klass
end

#modelObject (readonly)

Returns the value of attribute model.



7
8
9
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 7

def model
  @model
end

#ownersObject (readonly)

Returns the value of attribute owners.



7
8
9
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 7

def owners
  @owners
end

#preload_scopeObject (readonly)

Returns the value of attribute preload_scope.



7
8
9
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 7

def preload_scope
  @preload_scope
end

#preloaded_recordsObject (readonly)

Returns the value of attribute preloaded_records.



8
9
10
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 8

def preloaded_records
  @preloaded_records
end

#reflectionObject (readonly)

Returns the value of attribute reflection.



7
8
9
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 7

def reflection
  @reflection
end

Instance Method Details

#association_key_nameObject

The name of the key on the associated records

Raises:

  • (NotImplementedError)


28
29
30
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 28

def association_key_name
  raise NotImplementedError
end

#owner_key_nameObject

The name of the key on the model which declares the association

Raises:

  • (NotImplementedError)


33
34
35
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 33

def owner_key_name
  raise NotImplementedError
end

#preload(preloader) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 23

def preload(preloader)
  raise NotImplementedError
end

#run(preloader) ⇒ Object



19
20
21
# File 'activerecord/lib/active_record/associations/preloader/association.rb', line 19

def run(preloader)
  preload(preloader)
end