Permalink
Browse files

don't access the reflections hash

The reflections hash is supposed to be private, so let's use the API.
  • Loading branch information...
1 parent 9560369 commit 7e5c5e4d8c6c9346b8669db9faa4c3dced374646 @tenderlove tenderlove committed Oct 8, 2013
@@ -144,11 +144,15 @@ def cache_joined_association(association, tree)
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)
@@ -13,7 +13,7 @@ class JoinPart # :nodoc:
# 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

0 comments on commit 7e5c5e4

Please sign in to comment.