mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
22 lines
472 B
Ruby
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
|