From 928c84b65b6d34ca9cbfd698c1c01f8517d54ee1 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Mon, 2 Oct 2006 19:12:57 +0000 Subject: Fix issue with #class_inheritable_accessor saving updates to the parent class when initialized with an Array or Hash [mojombo] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5218 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_support/core_ext/class/inheritable_attributes.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb b/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb index 2e70a64436..bc8bf09ab2 100644 --- a/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb +++ b/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb @@ -107,7 +107,12 @@ class Class # :nodoc: private def inherited_with_inheritable_attributes(child) inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes) - child.instance_variable_set('@inheritable_attributes', inheritable_attributes.dup) + + new_inheritable_attributes = inheritable_attributes.inject({}) do |memo, (key, value)| + memo.update(key => (value.dup rescue value)) + end + + child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes) end alias inherited_without_inheritable_attributes inherited -- cgit v1.2.3