diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-06-08 16:57:46 -0400 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-06-08 17:05:29 -0400 |
commit | 87cc3d556948f4cb644091c98969c03e319c864e (patch) | |
tree | 81addbe0f0c4b3809c4c7392ca6d7e66e4eb4c65 /activerecord/lib/active_record | |
parent | f1c0bcfbb6878456d3d749a7c14f4753b53b23b6 (diff) | |
download | rails-87cc3d556948f4cb644091c98969c03e319c864e.tar.gz rails-87cc3d556948f4cb644091c98969c03e319c864e.tar.bz2 rails-87cc3d556948f4cb644091c98969c03e319c864e.zip |
Clarify Fixture#key_ and value_list
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/fixtures.rb | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 8099aaa7f7..82270c56b3 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -787,16 +787,14 @@ class Fixture #:nodoc: 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 |