dorian-to_struct 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/dorian/to_struct.rb +26 -0
- 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: d4f5ac19e990aa8f6bf562b7d81cdc16883fe2125f3ca3c49ed5c263fe9ea093
|
4
|
+
data.tar.gz: cca57932c680abb611f8607b04cc7c91c95afdb47ed32a13e3758336b6bebf31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26b356e92e535b244016df40bb9dc40063797799d0f915bbaaa0e1411d647552dc1ed8ab3081479fbb0ab5e95c138a4a59dd5ef586096ab18630aa05ed0ad782
|
7
|
+
data.tar.gz: 87d48e7153fa3343038347bce0a17420d3ab95cf60f9b9ec77f12527cac1322da106b986a640f2c0129336132ae82bfdd31ef435f2b365c681c0084ff8e5a42d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/dorian/to_struct.rb
CHANGED
@@ -3,9 +3,27 @@ class Array
|
|
3
3
|
map(&:to_struct)
|
4
4
|
end
|
5
5
|
|
6
|
+
def from_struct
|
7
|
+
map(&:from_struct)
|
8
|
+
end
|
9
|
+
|
6
10
|
def to_deep_struct
|
7
11
|
map(&:to_deep_struct)
|
8
12
|
end
|
13
|
+
|
14
|
+
def from_deep_struct
|
15
|
+
map(&:from_deep_struct)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Struct
|
20
|
+
def from_struct
|
21
|
+
to_h
|
22
|
+
end
|
23
|
+
|
24
|
+
def from_deep_struct
|
25
|
+
to_h { |key, value| [key, value.from_deep_struct] }
|
26
|
+
end
|
9
27
|
end
|
10
28
|
|
11
29
|
class Hash
|
@@ -26,4 +44,12 @@ class Object
|
|
26
44
|
def to_deep_struct
|
27
45
|
self
|
28
46
|
end
|
47
|
+
|
48
|
+
def from_struct
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def from_deep_struct
|
53
|
+
self
|
54
|
+
end
|
29
55
|
end
|