Method: ActiveRecord::Reflection::ClassMethods#reflections

Defined in:
lib/active_record/reflection.rb

#reflectionsObject

Returns a Hash of name of the reflection as the key and a AssociationReflection as the value.

Account.reflections # => {balance: AggregateReflection}


59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/active_record/reflection.rb', line 59

def reflections
  ref = {}
  _reflections.each do |name, reflection|
    parent_name, parent_reflection = reflection.parent_reflection
    if parent_name
      ref[parent_name] = parent_reflection
    else
      ref[name] = reflection
    end
  end
  ref
end