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: AbstractReflection, AggregateReflection, AssociationReflection, BelongsToReflection, HasAndBelongsToManyReflection, HasManyReflection, HasOneReflection, MacroReflection, PolymorphicReflection, RuntimeReflection, ThroughReflection

Class Method Summary collapse

Methods included from ActiveSupport::Concern

append_features, class_methods, 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 add_aggregate_reflection(ar, name, reflection)
  ar.aggregate_reflections = ar.aggregate_reflections.merge(-name.to_s => reflection)
end

.add_reflection(ar, name, reflection) ⇒ Object



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

def add_reflection(ar, name, reflection)
  ar.clear_reflections_cache
  name = -name.to_s
  ar._reflections = ar._reflections.except(name).merge!(name => reflection)
end

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



17
18
19
20
# File 'activerecord/lib/active_record/reflection.rb', line 17

def create(macro, name, scope, options, ar)
  reflection = reflection_class_for(macro).new(name, scope, options, ar)
  options[:through] ? ThroughReflection.new(reflection) : reflection
end