1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/arel/table.rb
2010-08-12 14:55:31 -07:00

22 lines
472 B
Ruby

module Arel
class Table
@engine = nil
class << self; attr_accessor :engine; end
def initialize name, engine = Table.engine
@name = name
@engine = engine
end
def columns
@engine.connection.columns(@name, "#{@name} Columns").map do |column|
Attributes.for(column).new self, column.name, column
end
end
def [] name
name = name.to_s
columns.find { |column| column.name == name }
end
end
end