aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/primitives
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-02-11 22:56:12 -0800
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-02-11 22:56:12 -0800
commit29d9b8e9b5899a8c52326dfca9343e79ba049d6b (patch)
tree4ca2605f94ca0d38d8aec1d689ec03713db54996 /lib/active_relation/primitives
parent61d6c2c1c5215014971355892e024682ed148ebb (diff)
downloadrails-29d9b8e9b5899a8c52326dfca9343e79ba049d6b.tar.gz
rails-29d9b8e9b5899a8c52326dfca9343e79ba049d6b.tar.bz2
rails-29d9b8e9b5899a8c52326dfca9343e79ba049d6b.zip
removing code complexity concerning attribute lookup.
Diffstat (limited to 'lib/active_relation/primitives')
-rw-r--r--lib/active_relation/primitives/attribute.rb10
-rw-r--r--lib/active_relation/primitives/expression.rb3
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/active_relation/primitives/attribute.rb b/lib/active_relation/primitives/attribute.rb
index e6df5cd87c..893feefef2 100644
--- a/lib/active_relation/primitives/attribute.rb
+++ b/lib/active_relation/primitives/attribute.rb
@@ -5,6 +5,10 @@ module ActiveRelation
def initialize(relation, name, aliaz = nil, ancestor = nil)
@relation, @name, @alias, @ancestor = relation, name, aliaz, ancestor
end
+
+ def alias_or_name
+ @alias || name
+ end
module Transformations
def as(aliaz = nil)
@@ -96,9 +100,11 @@ module ActiveRelation
strategy.attribute prefix, name, self.alias
end
- private
- delegate :hash, :to => :relation
+ def hash
+ relation.hash + name.hash
+ end
+ private
def prefix
relation.prefix_for(self)
end
diff --git a/lib/active_relation/primitives/expression.rb b/lib/active_relation/primitives/expression.rb
index a64219e9d1..ff07c40109 100644
--- a/lib/active_relation/primitives/expression.rb
+++ b/lib/active_relation/primitives/expression.rb
@@ -15,12 +15,10 @@ module ActiveRelation
end
def as(aliaz)
- # key line -- note self
Expression.new(attribute, function_sql, aliaz, self)
end
def to_attribute
- # key line -- note self
Attribute.new(relation, @alias, nil, self)
end
end
@@ -39,7 +37,6 @@ module ActiveRelation
!(history & other.send(:history)).empty?
end
- private
def hash
attribute.hash + function_sql.hash
end