aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/primitives
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/primitives')
-rw-r--r--lib/arel/primitives/attribute.rb55
1 files changed, 25 insertions, 30 deletions
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb
index 9215ea64a0..14b8c18cb2 100644
--- a/lib/arel/primitives/attribute.rb
+++ b/lib/arel/primitives/attribute.rb
@@ -1,13 +1,12 @@
module Arel
class Attribute
attr_reader :relation, :name, :alias, :ancestor
- delegate :engine, :to => :relation
+ delegate :engine, :christener, :to => :relation
def initialize(relation, name, options = {})
@relation, @name, @alias, @ancestor = relation, name, options[:alias], options[:ancestor]
end
- # INVESTIGATE
def alias_or_name
@alias || name
end
@@ -16,6 +15,30 @@ module Arel
false
end
+ def column
+ original_relation.column_for(self)
+ end
+
+ def original_relation
+ relation.relation_for(self)
+ end
+
+ def format(object)
+ object.to_sql(formatter)
+ end
+
+ def to_sql(formatter = Sql::WhereCondition.new(relation))
+ formatter.attribute self
+ end
+
+ def ==(other)
+ self.class == other.class and
+ relation == other.relation and
+ name == other.name and
+ @alias == other.alias and
+ ancestor == other.ancestor
+ end
+
module Transformations
def as(aliaz = nil)
Attribute.new(relation, name, :alias => aliaz, :ancestor => self)
@@ -31,18 +54,6 @@ module Arel
end
include Transformations
- def column
- relation.column_for(self)
- end
-
- def ==(other)
- self.class == other.class and
- relation == other.relation and
- name == other.name and
- @alias == other.alias and
- ancestor == other.ancestor
- end
-
module Congruence
def self.included(klass)
klass.hash_on :name
@@ -117,22 +128,6 @@ module Arel
end
end
include Expressions
-
- def to_sql(formatter = Sql::WhereCondition.new(relation))
- formatter.attribute self
- end
-
- def format(object)
- object.to_sql(formatter)
- end
-
- def original_relation
- relation.relation_for(self)
- end
-
- def christener
- relation.christener
- end
private
def formatter