Module: ActiveRecord::Reflection

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_record/reflection.rb

Overview

Active Record Reflection

Defined Under Namespace

Modules: ClassMethods Classes: AggregateReflection, AssociationReflection, MacroReflection, ThroughReflection

Class Method Summary collapse

Class Method Details

.add_aggregate_reflection(ar, name, reflection) ⇒ Object



28
29
30
# File 'lib/active_record/reflection.rb', line 28

def self.add_aggregate_reflection(ar, name, reflection)
  ar.aggregate_reflections = ar.aggregate_reflections.merge(name => reflection)
end

.add_reflection(ar, name, reflection) ⇒ Object



24
25
26
# File 'lib/active_record/reflection.rb', line 24

def self.add_reflection(ar, name, reflection)
  ar._reflections = ar._reflections.merge(name => reflection)
end

.create(macro, name, scope, options, ar) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/active_record/reflection.rb', line 13

def self.create(macro, name, scope, options, ar)
  case macro
  when :has_many, :belongs_to, :has_one
    klass = options[:through] ? ThroughReflection : AssociationReflection
  when :composed_of
    klass = AggregateReflection
  end

  klass.new(macro, name, scope, options, ar)
end