mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use a hash to look up column definitions
This commit is contained in:
parent
7e176a6d12
commit
76c29a64b9
1 changed files with 3 additions and 2 deletions
|
@ -66,6 +66,7 @@ module ActiveRecord
|
|||
|
||||
def initialize(base)
|
||||
@columns = []
|
||||
@columns_hash = {}
|
||||
@base = base
|
||||
end
|
||||
|
||||
|
@ -86,8 +87,7 @@ module ActiveRecord
|
|||
|
||||
# Returns a ColumnDefinition for the column with name +name+.
|
||||
def [](name)
|
||||
name = name.to_s
|
||||
@columns.find { |column| column.name == name }
|
||||
@columns_hash[name.to_s]
|
||||
end
|
||||
|
||||
# Instantiates a new column for the table.
|
||||
|
@ -283,6 +283,7 @@ module ActiveRecord
|
|||
def new_column_definition(base, name, type)
|
||||
definition = ColumnDefinition.new base, name, type
|
||||
@columns << definition
|
||||
@columns_hash[name] = definition
|
||||
definition
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue