recursive-open-struct 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16edd384bbe19b6efc58d29e12740a3756f6e51a
|
4
|
+
data.tar.gz: 97ad4a2805226395ef2df02f61f5482b37bc047f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 731c64834e1e18e6bcb2cd43fb112b6e87ebbabc6d63e31ce8cafaeb377e56f8601f2b9dcc4f02ecc2282f9a11c4176bb3dcd4f592e4126dad5ec6f9f4caf249
|
7
|
+
data.tar.gz: 173c905112efdc0d907af7de0730af75dd27fc733bd90a591bcb626048d5bb978c001d6e695b618db7204e214f17129ead2953c4fb573572da9ecd87ccd0280b
|
data/CHANGELOG.md
CHANGED
@@ -9,7 +9,8 @@ class RecursiveOpenStruct < OpenStruct
|
|
9
9
|
include Ruby19Backport if RUBY_VERSION =~ /\A1.9/
|
10
10
|
include DebugInspect
|
11
11
|
|
12
|
-
def initialize(hash=
|
12
|
+
def initialize(hash=nil, args={})
|
13
|
+
hash ||= {}
|
13
14
|
@recurse_over_arrays = args.fetch(:recurse_over_arrays, false)
|
14
15
|
@deep_dup = DeepDup.new(recurse_over_arrays: @recurse_over_arrays)
|
15
16
|
|
@@ -12,6 +12,23 @@ describe RecursiveOpenStruct do
|
|
12
12
|
ros.blah = "John Smith"
|
13
13
|
expect(ros.blah).to eq "John Smith"
|
14
14
|
end
|
15
|
+
|
16
|
+
it 'returns nil for missing attributes' do
|
17
|
+
expect(ros.foo).to be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when initialized with nil' do
|
22
|
+
let(:hash) { nil }
|
23
|
+
it 'returns nil for missing attributes' do
|
24
|
+
expect(ros.foo).to be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when initialized with an empty hash' do
|
29
|
+
it 'returns nil for missing attributes' do
|
30
|
+
expect(ros.foo).to be_nil
|
31
|
+
end
|
15
32
|
end
|
16
33
|
|
17
34
|
context "when initialized from a hash" do
|
@@ -5,7 +5,7 @@ describe RecursiveOpenStruct do
|
|
5
5
|
|
6
6
|
describe "recursive behavior" do
|
7
7
|
let(:h) { { :blah => { :another => 'value' } } }
|
8
|
-
subject { RecursiveOpenStruct.new(h) }
|
8
|
+
subject(:ros) { RecursiveOpenStruct.new(h) }
|
9
9
|
|
10
10
|
it "can convert the entire hash tree back into a hash" do
|
11
11
|
blank_obj = Object.new
|
@@ -280,5 +280,16 @@ describe RecursiveOpenStruct do
|
|
280
280
|
end
|
281
281
|
end # modifying an array and then recursing
|
282
282
|
end # recursing over arrays
|
283
|
+
|
284
|
+
describe 'nested nil values' do
|
285
|
+
let(:h) { { foo: { bar: nil }} }
|
286
|
+
it 'returns nil' do
|
287
|
+
expect(subject.foo.bar).to be_nil
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'returns a hash with the key and a nil value' do
|
291
|
+
expect(subject.to_hash).to eq({ foo: { bar: nil }})
|
292
|
+
end
|
293
|
+
end # nested nil values
|
283
294
|
end # recursive behavior
|
284
295
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recursive-open-struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William (B.J.) Snow Orvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|