diff options
author | Xavier Noria <fxn@hashref.com> | 2010-11-21 03:30:06 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-11-21 03:30:06 +0100 |
commit | 6af08ab6d835d1c2aa8648a0d3a4a86e678c3f52 (patch) | |
tree | 96bd668692b62d3829322232877b70c9011ce446 /activerecord/lib/active_record/reflection.rb | |
parent | f326221c701e4f9d991e3eadcc793a73795fb218 (diff) | |
parent | 7c51d1fcf9dc504c2dfd6e7184bbe8186f09819d (diff) | |
download | rails-6af08ab6d835d1c2aa8648a0d3a4a86e678c3f52.tar.gz rails-6af08ab6d835d1c2aa8648a0d3a4a86e678c3f52.tar.bz2 rails-6af08ab6d835d1c2aa8648a0d3a4a86e678c3f52.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index a2260e9a19..a07c321960 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -1,8 +1,15 @@ +require 'active_support/core_ext/class/attribute' + module ActiveRecord # = Active Record Reflection module Reflection # :nodoc: extend ActiveSupport::Concern + included do + class_attribute :reflections + self.reflections = {} + end + # Reflection enables to interrogate Active Record classes and objects # about their associations and aggregations. This information can, # for example, be used in a form builder that takes an Active Record object @@ -20,18 +27,9 @@ module ActiveRecord when :composed_of reflection = AggregateReflection.new(macro, name, options, active_record) end - write_inheritable_hash :reflections, name => reflection - reflection - end - # Returns a hash containing all AssociationReflection objects for the current class. - # Example: - # - # Invoice.reflections - # Account.reflections - # - def reflections - read_inheritable_attribute(:reflections) || write_inheritable_attribute(:reflections, {}) + self.reflections = self.reflections.merge(name => reflection) + reflection end # Returns an array of AggregateReflection objects for all the aggregations in the class. |