Skip to content

Commit 32e1508

Browse files
committed
Simplify initialize_dup
1 parent d517a27 commit 32e1508

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/recursive_open_struct.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ def delete_field(name)
170170

171171
unless OpenStruct.public_instance_methods.include?(:initialize_copy)
172172
def initialize_dup(orig)
173-
initialize(orig.to_hash, orig.instance_variable_get(:@options))
173+
super
174+
# deep copy the table to separate the two objects
175+
@table = @deep_dup.call(@table)
176+
# Forget any memoized sub-elements
177+
@sub_elements = {}
174178
end
175179
end
176180

0 commit comments

Comments
 (0)