recursive-open-struct 1.3.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0020068d7158163ebaa61a88a20513fda9662cabbb36227b9516c4c3579b579d'
4
- data.tar.gz: 95da83b2e949d013183b4f7715ca0820e71e12cebb6a91bd095cbef8c739013c
3
+ metadata.gz: 98947e3672ac602b5065c7cbd9db4712ad76f37f1bd93e7fe5b26bd03d45b868
4
+ data.tar.gz: 91d09d9bc788f331837fb9edfd5e1d006088becd07770ecea52a5b1dee2f659a
5
5
  SHA512:
6
- metadata.gz: c1a8203c90c1cda06131dd1bd342d928458af25d8a66880c80b9db1ebe5abbf411792b8377f73558e13f1815d8a2e6fb43b7b270cbd21d9202c8dedc9b3cc107
7
- data.tar.gz: c44fdc3e770d7f3be3ad5348174b62d36fe38c245516943195127152a549437fc26bb7a23047d79e3d71a08d12fdeebeb4bf12efd1b759172fedfde03625ecf1
6
+ metadata.gz: e37aaa9409d7cb1bf0b8999603bbaeb7345a2496784127ef2612b49b765a9a745b29fb4d6dcb3f5aee8045a89a2b05370611486db48be3e630cf8f22cfccfca6
7
+ data.tar.gz: 4d8cc8cd0140f749f7a924c06469a4d1cd1709fa3464cc72cec250c296e29cd1936fbc1dd6e9852c4fb904f6e0c1e65847b9ba311f48d41d75de12097ac2a409
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 2.0.0 / 2024/10/03
2
+ ==================
3
+
4
+ * BREAKING: Restore #72, which is an API-breaking change because it changes
5
+ what data is serialized with marshalling.
6
+
1
7
  1.3.1 / 2024/10/03
2
8
  ==================
3
9
 
@@ -3,5 +3,5 @@
3
3
  require 'ostruct'
4
4
 
5
5
  class RecursiveOpenStruct < OpenStruct
6
- VERSION = "1.3.1"
6
+ VERSION = "2.0.0"
7
7
  end
@@ -40,6 +40,16 @@ class RecursiveOpenStruct < OpenStruct
40
40
  @sub_elements = {}
41
41
  end
42
42
 
43
+ def marshal_load(attributes)
44
+ hash, @options = attributes
45
+ @deep_dup = DeepDup.new(@options)
46
+ @sub_elements = {}
47
+ super(hash)
48
+ end
49
+
50
+ def marshal_dump
51
+ [super, @options]
52
+ end
43
53
 
44
54
  if OpenStruct.public_instance_methods.include?(:initialize_copy)
45
55
  def initialize_copy(orig)
@@ -37,6 +37,14 @@ describe RecursiveOpenStruct do
37
37
  expect(ros.blah.changed).to eql 'backing'
38
38
  end
39
39
 
40
+ it "handles being dump then loaded by Marshal" do
41
+ foo_struct = [RecursiveOpenStruct.new]
42
+ bar_struct = RecursiveOpenStruct.new(foo: foo_struct)
43
+ serialized = Marshal.dump(bar_struct)
44
+
45
+ expect(Marshal.load(serialized).foo).to eq(foo_struct)
46
+ end
47
+
40
48
  describe "handling loops in the original Hashes" do
41
49
  let(:h1) { { :a => 'a'} }
42
50
  let(:h2) { { :a => 'b', :h1 => h1 } }
@@ -182,6 +190,17 @@ describe RecursiveOpenStruct do
182
190
  let(:blah_list) { [ { :foo => '1' }, { :foo => '2' }, 'baz' ] }
183
191
  let(:h) { { :blah => blah_list } }
184
192
 
193
+ context "when dump and loaded by Marshal" do
194
+ let(:test) { RecursiveOpenStruct.new(h, :recurse_over_arrays => true) }
195
+ subject { Marshal.load(Marshal.dump(test))}
196
+
197
+ it { expect(subject.blah.length).to eq 3 }
198
+ it { expect(subject.blah[0].foo).to eq '1' }
199
+ it { expect(subject.blah[1].foo).to eq '2' }
200
+ it { expect(subject.blah_as_a_hash).to eq blah_list }
201
+ it { expect(subject.blah[2]).to eq 'baz' }
202
+ end
203
+
185
204
  context "when recursing over arrays is enabled" do
186
205
  subject { RecursiveOpenStruct.new(h, :recurse_over_arrays => true) }
187
206
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recursive-open-struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William (B.J.) Snow Orvis