aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-08 14:10:57 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-08 14:10:57 -0700
commit7e5c5e4d8c6c9346b8669db9faa4c3dced374646 (patch)
tree25c92bb42079b21d20f92c508fad8b127aed05a5 /activerecord
parent95603695eced476125ab0dca9a12ee63539cc06b (diff)
downloadrails-7e5c5e4d8c6c9346b8669db9faa4c3dced374646.tar.gz
rails-7e5c5e4d8c6c9346b8669db9faa4c3dced374646.tar.bz2
rails-7e5c5e4d8c6c9346b8669db9faa4c3dced374646.zip
don't access the reflections hash
The reflections hash is supposed to be private, so let's use the API.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb8
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_part.rb2
2 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb
index c9c50da36e..80cf933555 100644
--- a/activerecord/lib/active_record/associations/join_dependency.rb
+++ b/activerecord/lib/active_record/associations/join_dependency.rb
@@ -144,11 +144,15 @@ module ActiveRecord
ref[association.reflection.name] ||= {}
end
+ def find_reflection(klass, name)
+ klass.reflect_on_association(name.intern) or
+ raise ConfigurationError, "Association named '#{ name }' was not found on #{ klass.name }; perhaps you misspelled it?"
+ end
+
def build(associations, parent, join_type)
case associations
when Symbol, String
- reflection = parent.reflections[associations.intern] or
- raise ConfigurationError, "Association named '#{ associations }' was not found on #{ parent.base_klass.name }; perhaps you misspelled it?"
+ reflection = find_reflection parent.base_klass, associations
unless join_association = find_join_association(reflection, parent)
@reflections << reflection
join_association = build_join_association(reflection, parent, join_type)
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_part.rb b/activerecord/lib/active_record/associations/join_dependency/join_part.rb
index 8024105472..2b6034ca9d 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_part.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_part.rb
@@ -13,7 +13,7 @@ module ActiveRecord
# association.
attr_reader :base_klass
- delegate :table_name, :column_names, :primary_key, :reflections, :arel_engine, :to => :base_klass
+ delegate :table_name, :column_names, :primary_key, :arel_engine, :to => :base_klass
def initialize(base_klass)
@base_klass = base_klass