Use map instead inject.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
Emilio Tagua 2010-09-22 11:04:11 -03:00 committed by Santiago Pastorino
parent 090c9ae3a3
commit 569be76ed6
1 changed files with 3 additions and 4 deletions

View File

@ -279,10 +279,9 @@ module ActiveRecord
# that a new instance, or one populated from a passed-in Hash, still has all the attributes
# that instances loaded from the database would.
def attributes_from_column_definition
self.class.columns.inject({}) do |attributes, column|
attributes[column.name] = column.default unless column.name == self.class.primary_key
attributes
end
Hash[self.class.columns.map do |column|
[column.name, column.default] unless column.name == self.class.primary_key
end]
end
end
end