From 116b6f05b0e72ce35808cb42dfbe4c543d8504ea Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Wed, 7 May 2008 00:32:32 -0700 Subject: removing operator overloading --- lib/arel/primitives/attribute.rb | 2 +- lib/arel/relations/relation.rb | 2 +- spec/arel/unit/primitives/attribute_spec.rb | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb index 30c03839e2..78a519b35c 100644 --- a/lib/arel/primitives/attribute.rb +++ b/lib/arel/primitives/attribute.rb @@ -65,7 +65,7 @@ module Arel [self] + (ancestor ? [ancestor, ancestor.history].flatten : []) end - def =~(other) + def match?(other) !(history & other.history).empty? end diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index fc47a129a0..250eb85222 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -141,7 +141,7 @@ module Arel # TESTME - added relation_for(x)[x] because of AR def attribute_for_attribute(attribute) - attributes.select { |a| a =~ attribute }.max do |a1, a2| + attributes.select { |a| a.match?(attribute) }.max do |a1, a2| (attribute / relation_for(a1)[a1]) <=> (attribute / relation_for(a2)[a2]) end end diff --git a/spec/arel/unit/primitives/attribute_spec.rb b/spec/arel/unit/primitives/attribute_spec.rb index b253892b58..e21a5902d5 100644 --- a/spec/arel/unit/primitives/attribute_spec.rb +++ b/spec/arel/unit/primitives/attribute_spec.rb @@ -45,15 +45,15 @@ module Arel end describe Attribute::Congruence do - describe '=~' do + describe 'match?' do it "obtains if the attributes are identical" do - Attribute.new(@relation, :name).should =~ Attribute.new(@relation, :name) + Attribute.new(@relation, :name).should be_match(Attribute.new(@relation, :name)) end it "obtains if the attributes have an overlapping history" do - Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name)).should =~ Attribute.new(@relation, :name) - Attribute.new(@relation, :name).should =~ Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name)) + Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name)).should be_match(Attribute.new(@relation, :name)) + Attribute.new(@relation, :name).should be_match(Attribute.new(@relation, :name, :ancestor => Attribute.new(@relation, :name))) end end -- cgit v1.2.3