Skip to content

Commit

Permalink
Revert "Merge pull request #72 from wildmaples/fix-marshal-load-issue"
Browse files Browse the repository at this point in the history
This reverts commit 7ece1dd, reversing
changes made to 09f651d.
  • Loading branch information
aetherknight committed Oct 4, 2024
1 parent 3f526d5 commit 49265a8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
10 changes: 0 additions & 10 deletions lib/recursive_open_struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ def initialize(hash=nil, passed_options={})
@sub_elements = {}
end

def marshal_load(attributes)
hash, @options = attributes
@deep_dup = DeepDup.new(@options)
@sub_elements = {}
super(hash)
end

def marshal_dump
[super, @options]
end

if OpenStruct.public_instance_methods.include?(:initialize_copy)
def initialize_copy(orig)
Expand Down
19 changes: 0 additions & 19 deletions spec/recursive_open_struct/recursion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
expect(ros.blah.changed).to eql 'backing'
end

it "handles being dump then loaded by Marshal" do
foo_struct = [RecursiveOpenStruct.new]
bar_struct = RecursiveOpenStruct.new(foo: foo_struct)
serialized = Marshal.dump(bar_struct)

expect(Marshal.load(serialized).foo).to eq(foo_struct)
end

describe "handling loops in the original Hashes" do
let(:h1) { { :a => 'a'} }
let(:h2) { { :a => 'b', :h1 => h1 } }
Expand Down Expand Up @@ -190,17 +182,6 @@
let(:blah_list) { [ { :foo => '1' }, { :foo => '2' }, 'baz' ] }
let(:h) { { :blah => blah_list } }

context "when dump and loaded by Marshal" do
let(:test) { RecursiveOpenStruct.new(h, :recurse_over_arrays => true) }
subject { Marshal.load(Marshal.dump(test))}

it { expect(subject.blah.length).to eq 3 }
it { expect(subject.blah[0].foo).to eq '1' }
it { expect(subject.blah[1].foo).to eq '2' }
it { expect(subject.blah_as_a_hash).to eq blah_list }
it { expect(subject.blah[2]).to eq 'baz' }
end

context "when recursing over arrays is enabled" do
subject { RecursiveOpenStruct.new(h, :recurse_over_arrays => true) }

Expand Down

0 comments on commit 49265a8

Please sign in to comment.