diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-07 00:36:37 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-07 00:36:37 -0700 |
commit | ea111521b7eb7456934a283d96f6eb986322baf2 (patch) | |
tree | eecb4a945d0d290ce3698a0be7ea7fe66bdc4992 /lib | |
parent | 116b6f05b0e72ce35808cb42dfbe4c543d8504ea (diff) | |
download | rails-ea111521b7eb7456934a283d96f6eb986322baf2.tar.gz rails-ea111521b7eb7456934a283d96f6eb986322baf2.tar.bz2 rails-ea111521b7eb7456934a283d96f6eb986322baf2.zip |
renamed attribute_for_attribute to find_attribute_matching_attribute
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/relations/relation.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index 250eb85222..4653323514 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -127,32 +127,33 @@ module Arel def [](index) case index when Symbol, String - attribute_for_name(index) + find_attribute_matching_name(index) when Attribute, Expression - attribute_for_attribute(index) + find_attribute_matching_attribute(index) when Array index.collect { |i| self[i] } end end - def attribute_for_name(name) + def find_attribute_matching_name(name) attributes.detect { |a| a.alias_or_name.to_s == name.to_s } end # TESTME - added relation_for(x)[x] because of AR - def attribute_for_attribute(attribute) + def find_attribute_matching_attribute(attribute) attributes.select { |a| a.match?(attribute) }.max do |a1, a2| + # FIXME relation_for(a1)[a1] should be a1.original or something (attribute / relation_for(a1)[a1]) <=> (attribute / relation_for(a2)[a2]) end end - def attribute_for_attribute_with_memoization(attribute) + def find_attribute_matching_attribute_with_memoization(attribute) @attribute_for_attribute ||= Hash.new do |h, a| - h[a] = attribute_for_attribute_without_memoization(a) + h[a] = find_attribute_matching_attribute_without_memoization(a) end @attribute_for_attribute[attribute] end - alias_method_chain :attribute_for_attribute, :memoization + alias_method_chain :find_attribute_matching_attribute, :memoization end include AttributeAccessable |