From f48c642852b5bb6be62dbbc7502d34b64e53716b Mon Sep 17 00:00:00 2001 From: Nick Kallen Date: Wed, 30 Apr 2008 23:42:26 -0700 Subject: the big obstacle --- lib/arel/relations/alias.rb | 12 +++--------- lib/arel/relations/compound.rb | 2 +- lib/arel/relations/join.rb | 5 +++++ lib/arel/relations/relation.rb | 9 ++------- 4 files changed, 11 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/arel/relations/alias.rb b/lib/arel/relations/alias.rb index 2dab52515f..329f94638e 100644 --- a/lib/arel/relations/alias.rb +++ b/lib/arel/relations/alias.rb @@ -2,18 +2,12 @@ module Arel class Alias < Compound attr_reader :alias - def initialize(relation, aliaz) - @relation, @alias = relation, aliaz - end - - def alias? - true + def initialize(relation) + @relation = relation end def ==(other) - self.class == other.class and - relation == other.relation and - @alias == other.alias + self.equal? other end end end \ No newline at end of file diff --git a/lib/arel/relations/compound.rb b/lib/arel/relations/compound.rb index 4ffac6d1c3..ae848433be 100644 --- a/lib/arel/relations/compound.rb +++ b/lib/arel/relations/compound.rb @@ -5,7 +5,7 @@ module Arel hash_on :relation delegate :joins, :selects, :orders, :groupings, :table_sql, :inserts, :taken, - :skipped, :name, :alias, :aggregation?, :alias?, :prefix_for, :column_for, + :skipped, :name, :alias, :aggregation?, :prefix_for, :column_for, :engine, :to => :relation diff --git a/lib/arel/relations/join.rb b/lib/arel/relations/join.rb index ce236d79d0..6c12a0ea26 100644 --- a/lib/arel/relations/join.rb +++ b/lib/arel/relations/join.rb @@ -48,6 +48,11 @@ module Arel [relation1.joins, relation2.joins, this_join].compact.join(" ") end + # FIXME + def name + 'user' + end + def selects (externalize(relation1).selects + externalize(relation2).selects).collect { |s| s.bind(self) } end diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index 0a5bf2ff24..3453b9adc6 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -52,8 +52,8 @@ module Arel attributes.all?(&:blank?) ? self : Projection.new(self, *attributes) end - def as(aliaz = nil) - aliaz.blank?? self : Alias.new(self, aliaz) + def alias + Alias.new(self) end def order(*attributes) @@ -100,10 +100,6 @@ module Arel false end - def alias? - false - end - def relation_for(attribute) self[attribute] and self end @@ -166,6 +162,5 @@ module Arel def joins; nil end def taken; nil end def skipped; nil end - def alias; nil end end end \ No newline at end of file -- cgit v1.2.3