aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-11-14 12:37:25 -0700
committerSean Griffin <sean@thoughtbot.com>2014-11-14 14:30:40 -0700
commit48f2620df98e6926d38b8951087ab1bbc512580c (patch)
treecf4b0c7bf818773c75219d9018afa88ebe821c50 /activerecord/lib
parent895a53e7161e9bdc6285fe03f16b49ec74972416 (diff)
downloadrails-48f2620df98e6926d38b8951087ab1bbc512580c.tar.gz
rails-48f2620df98e6926d38b8951087ab1bbc512580c.tar.bz2
rails-48f2620df98e6926d38b8951087ab1bbc512580c.zip
Don't freeze the same hash we use for memoization
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attribute_set/builder.rb13
1 files 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