提交 48f2620d 编写于 作者: S Sean Griffin

Don't freeze the same hash we use for memoization

上级 895a53e7
......@@ -23,7 +23,6 @@ def build_from_database(values = {}, additional_types = {})
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 @@ def [](key)
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 @@ def initialize_dup(_)
super
end
def initialize_clone(_)
@delegate_hash = delegate_hash.clone
super
end
protected
attr_reader :types, :values, :additional_types, :delegate_hash
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册