aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-04-22 09:47:40 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-04-22 10:00:23 -0700
commitd692e6be3091dd114afa0cce2778787d3af93e83 (patch)
tree329c241653fdfd2e80ffc700c6da0247be1ae5e7
parentebf9820f7eb83476d200c71915dd0e8a056bcbab (diff)
downloadrails-d692e6be3091dd114afa0cce2778787d3af93e83.tar.gz
rails-d692e6be3091dd114afa0cce2778787d3af93e83.tar.bz2
rails-d692e6be3091dd114afa0cce2778787d3af93e83.zip
Restore HWIA#stringify_keys! and update changelog
-rwxr-xr-xactiverecord/lib/active_record/base.rb3
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb4
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb6
4 files changed, 8 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index fd24dcddc3..2d7cfad80d 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1844,8 +1844,7 @@ module ActiveRecord #:nodoc:
# user.is_admin? # => true
def attributes=(new_attributes, guard_protected_attributes = true)
return if new_attributes.nil?
- attributes = new_attributes.dup
- attributes.stringify_keys!
+ attributes = new_attributes.stringify_keys
multi_parameter_attributes = []
attributes = remove_attributes_protected_from_mass_assignment(attributes) if guard_protected_attributes
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index da370303c6..5ada5a1e9b 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*Rails 3.0.0 [beta 3] (April 13th, 2010)*
+* HashWithIndifferentAccess: remove inherited symbolize_keys! since its keys are always strings. [Santiago Pastorino]
+
* Improve transliteration quality. #4374 [Norman Clarke]
* Speed up and add Ruby 1.9 support for ActiveSupport::Multibyte::Chars#tidy_bytes. #4350 [Norman Clarke]
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index 4de399a21a..21407327cd 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -111,8 +111,8 @@ module ActiveSupport
super(convert_key(key))
end
- undef :stringify_keys!
- def stringify_keys; to_hash.stringify_keys end
+ def stringify_keys!; self end
+ def stringify_keys; to_hash end
undef :symbolize_keys!
def symbolize_keys; to_hash.symbolize_keys end
def to_options!; self end
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index bac6d16ac5..1dcde4b665 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -89,9 +89,9 @@ class HashExtTest < Test::Unit::TestCase
end
def test_stringify_keys_bang_for_hash_with_indifferent_access
- assert_raise(NoMethodError) { @symbols.with_indifferent_access.dup.stringify_keys! }
- assert_raise(NoMethodError) { @strings.with_indifferent_access.dup.stringify_keys! }
- assert_raise(NoMethodError) { @mixed.with_indifferent_access.dup.stringify_keys! }
+ assert_equal @strings, @symbols.with_indifferent_access.dup.stringify_keys!
+ assert_equal @strings, @strings.with_indifferent_access.dup.stringify_keys!
+ assert_equal @strings, @mixed.with_indifferent_access.dup.stringify_keys!
end
def test_indifferent_assorted