From 67a3a702951dae905b6270d652dbd14853b01c26 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 30 Oct 2010 08:45:40 -0700 Subject: refactoring find_join_association --- activerecord/lib/active_record/associations.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index b8cd2aa31e..dc466eafc2 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1960,12 +1960,13 @@ module ActiveRecord end def find_join_association(name_or_reflection, parent) - case name_or_reflection - when Symbol, String - join_associations.detect {|j| (j.reflection.name == name_or_reflection.to_s.intern) && (j.parent == parent)} - else - join_associations.detect {|j| (j.reflection == name_or_reflection) && (j.parent == parent)} + if String === name_or_reflection + name_or_reflection = name_or_reflection.to_sym end + + join_associations.detect { |j| + j.reflection == name_or_reflection && j.parent == parent + } end def remove_uniq_by_reflection(reflection, records) -- cgit v1.2.3