From 60f8668d41d45b21d962bdc534bbc417d22e701b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 6 Aug 2010 14:19:09 -0700 Subject: initializing instance variables, converting to attr-reader --- lib/arel/algebra/attributes/attribute.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/arel/algebra') diff --git a/lib/arel/algebra/attributes/attribute.rb b/lib/arel/algebra/attributes/attribute.rb index 5b391f86b0..16124abcc4 100644 --- a/lib/arel/algebra/attributes/attribute.rb +++ b/lib/arel/algebra/attributes/attribute.rb @@ -4,12 +4,17 @@ module Arel class TypecastError < StandardError ; end class Attribute attr_reader :relation, :name, :alias, :ancestor, :hash + attr_reader :history, :root def initialize(relation, name, options = {}) @relation = relation # this is actually a table (I think) @name = name @alias = options[:alias] @ancestor = options[:ancestor] + @history = [self] + (@ancestor ? @ancestor.history : []) + @root = @history.last + @original_relation = nil + @original_attribute = nil # FIXME: I think we can remove this eventually @hash = name.hash + root.relation.class.hash @@ -58,10 +63,6 @@ module Arel bind(relation) end - def history - @history ||= [self] + (ancestor ? ancestor.history : []) - end - def join? relation.join? end -- cgit v1.2.3