diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-13 11:30:24 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-13 11:30:24 -0700 |
commit | bfe0348889d17737b91604d48c529d31ab8b9c1c (patch) | |
tree | 103bf7c61a50f529ef6b88854fceb8f3071aa114 | |
parent | 38b10d5ea1411e4adcbb190cc6a38c9529b8998c (diff) | |
download | rails-bfe0348889d17737b91604d48c529d31ab8b9c1c.tar.gz rails-bfe0348889d17737b91604d48c529d31ab8b9c1c.tar.bz2 rails-bfe0348889d17737b91604d48c529d31ab8b9c1c.zip |
table responds to where, column info is cached
-rw-r--r-- | lib/arel/table.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb index 3d0fae07b4..4c0404b492 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -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 |