From 48f2620df98e6926d38b8951087ab1bbc512580c Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 14 Nov 2014 12:37:25 -0700 Subject: Don't freeze the same hash we use for memoization --- activerecord/lib/active_record/attribute_set/builder.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/activerecord/lib/active_record/attribute_set/builder.rb b/activerecord/lib/active_record/attribute_set/builder.rb index 4134032659..73b77d2eda 100644 --- a/activerecord/lib/active_record/attribute_set/builder.rb +++ b/activerecord/lib/active_record/attribute_set/builder.rb @@ -23,7 +23,6 @@ module ActiveRecord class LazyAttributeHash delegate :select, :transform_values, to: :materialize - delegate :[]=, :freeze, to: :delegate_hash def initialize(types, values, additional_types) @types = types @@ -45,6 +44,13 @@ module ActiveRecord end end + def []=(key, value) + if frozen? + raise RuntimeError, "Can't modify frozen hash" + end + delegate_hash[key] = value + end + def initialized_keys delegate_hash.keys | values.keys end @@ -54,11 +60,6 @@ module ActiveRecord super end - def initialize_clone(_) - @delegate_hash = delegate_hash.clone - super - end - protected attr_reader :types, :values, :additional_types, :delegate_hash -- cgit v1.2.3