tiny_dot 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiny_dot.rb +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3ec8b3c35fead6132ebda8b96bae5b856bc106092c5a474ba326551177d3372
|
4
|
+
data.tar.gz: 527e7a75b8761a4273db4ebc84516797727b144adef06afc8fe105e2b88713da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc9ee68882c48f76fa70601f2ccb57c3468de75ec3793a07660390e9ea8b5c60066e731155353a34ce6256b11d833b9a01024962609a4f054a4d7313034552cb
|
7
|
+
data.tar.gz: f7c25df59caa78c9df9f2a471580e884b77690db316dc579e3ed37798bbdf1f45e2f4b48a44c246f6aea88f82e1348713060cf40cf0c2ecae4b49bd51920be19
|
data/lib/tiny_dot.rb
CHANGED
@@ -66,15 +66,17 @@ module TinyDot
|
|
66
66
|
_hash_to_struct(hash)
|
67
67
|
end
|
68
68
|
|
69
|
-
def _hash_to_struct(
|
70
|
-
case
|
69
|
+
def _hash_to_struct(obj)
|
70
|
+
case obj
|
71
71
|
when Hash
|
72
|
-
|
73
|
-
|
72
|
+
return obj if obj.keys.empty?
|
73
|
+
|
74
|
+
struct = ::Struct.new(*_to_attr_friendly_symbols(obj.keys))
|
75
|
+
struct.new(*obj.values.map { |v| _hash_to_struct(v) })
|
74
76
|
when Array
|
75
|
-
|
77
|
+
obj.map { |v| _hash_to_struct(v) }
|
76
78
|
else
|
77
|
-
|
79
|
+
obj
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|