recursive-open-struct 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/recursive_open_struct.rb +2 -3
- data/lib/recursive_open_struct/version.rb +1 -1
- data/spec/recursive_open_struct_spec.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1f1a8f65c6217fb268d9cb42d7a862c17331c9a
|
4
|
+
data.tar.gz: 0ac4e5cd8da82078b32e3c782668e1446f2383bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ccb7649bea9011276fa62f1f5e1d22956446d846d41320616e1a1b83738bf1ede1baa128cc9fa2d283e1b591dbc8f765dcbde1f64ffd7a367535edda95114e1
|
7
|
+
data.tar.gz: 5c762d9925b274435e1753b1c24b4b4e84ddc49f84cc2780c40e39fd01aa803eb071b8f9afc1484aa974500fa08a34ccaf5c12602bafeb55131a22483b413ec3
|
data/CHANGELOG.md
CHANGED
@@ -12,7 +12,7 @@ class RecursiveOpenStruct < OpenStruct
|
|
12
12
|
@deep_dup = DeepDup.new(recurse_over_arrays: @recurse_over_arrays)
|
13
13
|
|
14
14
|
@table = args.fetch(:mutate_input_hash, false) ? hash : @deep_dup.call(hash)
|
15
|
-
@table && @table.each_key { |k| new_ostruct_member(k
|
15
|
+
@table && @table.each_key { |k| new_ostruct_member(k) }
|
16
16
|
|
17
17
|
@sub_elements = {}
|
18
18
|
end
|
@@ -22,7 +22,7 @@ class RecursiveOpenStruct < OpenStruct
|
|
22
22
|
|
23
23
|
# Apply fix if necessary:
|
24
24
|
# https://github.com/ruby/ruby/commit/2d952c6d16ffe06a28bb1007e2cd1410c3db2d58
|
25
|
-
@table.each_key{|key| new_ostruct_member(key)} if RUBY_VERSION =~ /^1.9/
|
25
|
+
@table.each_key{|key| new_ostruct_member(key)} if RUBY_VERSION =~ /^1.9/
|
26
26
|
|
27
27
|
# deep copy the table to separate the two objects
|
28
28
|
@table = @deep_dup.call(orig.instance_variable_get(:@table))
|
@@ -41,7 +41,6 @@ class RecursiveOpenStruct < OpenStruct
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def new_ostruct_member(name)
|
44
|
-
name = name.to_sym
|
45
44
|
unless self.respond_to?(name)
|
46
45
|
class << self; self; end.class_eval do
|
47
46
|
define_method(name) do
|
@@ -11,10 +11,18 @@ describe RecursiveOpenStruct do
|
|
11
11
|
ros.blah.should == "John Smith"
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
context "can be created from a hash" do
|
15
|
+
it "and keys are instanced as symbol" do
|
16
|
+
h = { :asdf => 'John Smith' }
|
17
|
+
ros = RecursiveOpenStruct.new(h)
|
18
|
+
ros.asdf.should == "John Smith"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "and keys are instanced as string" do
|
22
|
+
h = { "asdf" => 'John Smith' }
|
23
|
+
ros = RecursiveOpenStruct.new(h)
|
24
|
+
ros.asdf.should == "John Smith"
|
25
|
+
end
|
18
26
|
end
|
19
27
|
|
20
28
|
it "can modify an existing key" do
|
@@ -154,7 +162,7 @@ describe RecursiveOpenStruct do
|
|
154
162
|
RecursiveOpenStruct.new(
|
155
163
|
{ :blah => original_blah }, :recurse_over_arrays => true)
|
156
164
|
end
|
157
|
-
|
165
|
+
|
158
166
|
before(:each) { subject.blah } # enforce memoization
|
159
167
|
|
160
168
|
context "when modifying an entire Hash" do
|
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.3
|
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-04-
|
11
|
+
date: 2015-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|