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, class_methods, extended, included

Class Method Details

+ (Object) add_aggregate_reflection(ar, name, reflection)



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_s => reflection)
end

+ (Object) add_reflection(ar, name, reflection)



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_s => reflection)
end

+ (Object) create(macro, name, scope, options, ar)



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