Module: ActiveRecord::Reflection

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

Overview

Active Record Reflection

Defined Under Namespace

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

Class Method Summary collapse

Methods included from ActiveSupport::Concern

append_features, extended, included

Class Method Details

.add_aggregate_reflection(ar, name, reflection) ⇒ Object


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

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

.add_reflection(ar, name, reflection) ⇒ Object


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

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

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


13
14
15
16
17
18
19
20
21
22
# File 'activerecord/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