1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

table responds to where, column info is cached

This commit is contained in:
Aaron Patterson 2010-08-13 11:30:24 -07:00
parent 38b10d5ea1
commit bfe0348889

View file

@ -6,16 +6,21 @@ module Arel
attr_reader :name, :engine
def initialize name, engine = Table.engine
@name = name
@engine = engine
@name = name
@engine = engine
@columns = nil
end
def tm
TreeManager.new(@engine).from(self)
end
def where condition
tm.where condition
end
def columns
@engine.connection.columns(@name, "#{@name} Columns").map do |column|
@columns ||= @engine.connection.columns(@name, "#{@name} Columns").map do |column|
Attributes.for(column).new self, column.name, column
end
end