提交 58c7733b 编写于 作者: A Aaron Patterson

speed up hash calculation and hash method

上级 635f11d7
......@@ -3,13 +3,16 @@
module Arel
class TypecastError < StandardError ; end
class Attribute
attr_reader :relation, :name, :alias, :ancestor
attr_reader :relation, :name, :alias, :ancestor, :hash
def initialize(relation, name, options = {})
@relation = relation # this is actually a table (I think)
@name = name
@alias = options[:alias]
@ancestor = options[:ancestor]
# FIXME: I think we can remove this eventually
@hash = name.hash + root.relation.class.hash
end
def engine
......@@ -23,10 +26,10 @@ def christener
def == other
super ||
Attribute === other &&
@relation == other.relation &&
@name == other.name &&
@alias == other.alias &&
@ancestor == other.ancestor
@ancestor == other.ancestor &&
@relation == other.relation
end
alias :eql? :==
......@@ -43,10 +46,6 @@ def eval(row)
row[self]
end
def hash
@hash ||= name.hash + root.relation.hash
end
def as(aliaz = nil)
Attribute.new(relation, name, :alias => aliaz, :ancestor => self)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册