dorian-to_struct 0.2.0 → 0.2.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 +5 -7
- data/lib/dorian/to_struct.rb +2 -0
- data/lib/dorian-to_struct.rb +2 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1cda01a7c0a27a312357aa4ca3e4f2d298be70f40addbc211ba4397523b25a5
|
4
|
+
data.tar.gz: 670052320db935fd912619b6f83007a1cf1a951f4e82439b189b75eac0e18409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55126ce614849a9cdebebd63b6533f330c121fd3a5c0f510be91de1ad030f7f965a30b91c631a95791e366908497f66d6b0045ba946ce72f1665c53af8d6a6a6
|
7
|
+
data.tar.gz: 96d8be2a7adfce566c0a665f18df0532ee3087eadaf65e6512f6e4cd25af1f57d7e45ab85514cd63dfc1229e41848b777b7535c45f9a98e581689553f690fea7
|
@@ -17,12 +17,10 @@ class Hash
|
|
17
17
|
# user.events.first.name # => "Party"
|
18
18
|
#
|
19
19
|
def to_deep_struct
|
20
|
-
Struct
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
)
|
20
|
+
Struct.new(*keys.map(&:to_sym)).new(
|
21
|
+
*values.map do |value|
|
22
|
+
value.respond_to?(:to_deep_struct) ? value.to_deep_struct : value
|
23
|
+
end
|
24
|
+
)
|
27
25
|
end
|
28
26
|
end
|
data/lib/dorian/to_struct.rb
CHANGED
data/lib/dorian-to_struct.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorian-to_struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Adds `#to_struct` and `#to_deep_struct` to Hash and Array
|
15
15
|
|
16
16
|
e.g. user.first_name, user.events.first.name, etc.
|
17
|
-
email: dorian@dorianmarie.
|
17
|
+
email: dorian@dorianmarie.com
|
18
18
|
executables: []
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
@@ -23,7 +23,7 @@ files:
|
|
23
23
|
- lib/dorian/core_ext/array/struct.rb
|
24
24
|
- lib/dorian/core_ext/hash/struct.rb
|
25
25
|
- lib/dorian/to_struct.rb
|
26
|
-
homepage: https://github.com/
|
26
|
+
homepage: https://github.com/dorianmariecom/to_struct
|
27
27
|
licenses:
|
28
28
|
- MIT
|
29
29
|
metadata:
|
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
45
|
requirements: []
|
46
|
-
rubygems_version: 3.
|
46
|
+
rubygems_version: 3.5.3
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: Adds `#to_struct` and `#to_deep_struct` to Hash and Array
|