dorian-to_struct 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dorian/core_ext/hash/struct.rb +2 -2
- 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: 49bd0ba3de934523a001e901d7337f9de71b7af79d1ad4f27d9fa708c412a516
|
4
|
+
data.tar.gz: 2980eee293f67aff8b1fa406ad12c79ee276d16c3b7d5388f76e45c46d5540d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f3cdacb5b1b7831d3e7ebcb04027631750e7b29566cd01489143880d1b9978118a3bdb030417581afb53187b99330a6beeee7c401d1deb8c22d1c4c7c4df5c
|
7
|
+
data.tar.gz: f1f29b0affd933fe06733bfdff354782a59a94dba9d81cabb03832109cc3b0a82046502e5423dbf23005119dfe72896b4f7615a89994d954937edfae9e97fd30
|
@@ -8,7 +8,7 @@ class Hash
|
|
8
8
|
# user.birthdate # => NoMethodError: undefined method `birthdate' for <struct...>
|
9
9
|
#
|
10
10
|
def to_struct
|
11
|
-
Struct.new(*keys).new(*values)
|
11
|
+
Struct.new(*keys.map(&:to_sym)).new(*values)
|
12
12
|
end
|
13
13
|
|
14
14
|
# Returns a new struct with the same key/value pairs
|
@@ -18,7 +18,7 @@ class Hash
|
|
18
18
|
#
|
19
19
|
def to_deep_struct
|
20
20
|
Struct
|
21
|
-
.new(*keys)
|
21
|
+
.new(*keys.map(&:to_sym))
|
22
22
|
.new(
|
23
23
|
*values.map do |value|
|
24
24
|
value.respond_to?(:to_deep_struct) ? value.to_deep_struct : value
|