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:
parent
38b10d5ea1
commit
bfe0348889
1 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue