Method: ActiveRecord::Reflection::ClassMethods#reflections
- Defined in:
- lib/active_record/reflection.rb
#reflections ⇒ Object
Returns a Hash of name of the reflection as the key and an AssociationReflection as the value.
Account.reflections # => {"balance" => AggregateReflection}
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/active_record/reflection.rb', line 74 def reflections @__reflections ||= begin ref = {} _reflections.each do |name, reflection| parent_reflection = reflection.parent_reflection if parent_reflection parent_name = parent_reflection.name ref[parent_name.to_s] = parent_reflection else ref[name] = reflection end end ref end end |