Permalink
Browse files

Clarify Fixture#key_ and value_list

  • Loading branch information...
jeremy committed Jun 8, 2010
1 parent f1c0bcf commit 87cc3d556948f4cb644091c98969c03e319c864e
Showing with 5 additions and 7 deletions.
  1. +5 −7 activerecord/lib/active_record/fixtures.rb
@@ -787,16 +787,14 @@ def to_hash
end
def key_list
- columns = @fixture.keys.collect{ |column_name| @connection.quote_column_name(column_name) }
- columns.join(", ")
+ @fixture.keys.map { |column_name| @connection.quote_column_name(column_name) }.join(', ')
end
def value_list
- list = @fixture.inject([]) do |fixtures, (key, value)|
- col = model_class.columns_hash[key] if model_class.respond_to?(:ancestors) && model_class.ancestors.include?(ActiveRecord::Base)
- fixtures << @connection.quote(value, col).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r")
- end
- list * ', '
+ cols = (model_class && model_class < ActiveRecord::Base) ? model_class.columns_hash : {}
+ @fixture.map do |key, value|
+ @connection.quote(value, cols[key]).gsub('[^\]\\n', "\n").gsub('[^\]\\r', "\r")
+ end.join(', ')
end
def find

0 comments on commit 87cc3d5

Please sign in to comment.