From e15b371777b72b6f2e71f27c5d55768083c87996 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 26 Nov 2004 00:50:49 +0000 Subject: symbolize_strings_in_hash shouldnt change receiver -- this should fix the bug with dump_schema in the rakefile git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@17 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_record/connection_adapters/abstract_adapter.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 3d6290f50f..d3ba329406 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -85,7 +85,7 @@ module ActiveRecord when Symbol, String establish_connection(configurations[spec.to_s]) else - symbolize_strings_in_hash(spec) + spec = symbolize_strings_in_hash(spec) unless spec.key?(:adapter) then raise AdapterNotSpecified end adapter_method = "#{spec[:adapter]}_connection" @@ -149,11 +149,9 @@ module ActiveRecord # Converts all strings in a hash to symbols. def self.symbolize_strings_in_hash(hash) - hash.each do |key, value| - if key.class == String - hash.delete key - hash[key.intern] = value - end + hash.inject({}) do |hash_with_symbolized_strings, pair| + hash_with_symbolized_strings[pair.first.to_sym] = pair.last + hash_with_symbolized_strings end end end -- cgit v1.2.3