dry-types-tuple 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dry-types-tuple.gemspec +1 -1
- data/lib/dry/tuple.rb +14 -7
- 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: fd3228e18cf0642b5270041045dcd053ab2ae71b46246420e1a58f0c3fb1dda7
|
4
|
+
data.tar.gz: 58e0adf146063babf2b35beeabcfda9f531f2c00b1075fa7f5e017d6c5cd00ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29847469e31c10ead9a61e7afedf3ddc98b1b2dd9cea975237d0a72642778b93dbe4bca20230c28ef511809d67471d86ead90165468da1744df510ab2e11fe5f
|
7
|
+
data.tar.gz: 96b53068b51630699c1c6e5c943c9671da97b0b15d09c8286929a51105a24e0e6ec2c2f89a89c2cba88239e9d37cb1bb12b91ac7dd471f4546e705a3b7f68e61
|
data/dry-types-tuple.gemspec
CHANGED
data/lib/dry/tuple.rb
CHANGED
@@ -24,13 +24,6 @@ module Dry
|
|
24
24
|
module Tuple
|
25
25
|
# Pure class type decorator mixin.
|
26
26
|
module ClassDecorator
|
27
|
-
include Types::Decorator
|
28
|
-
|
29
|
-
# @return [@tuple]
|
30
|
-
def type
|
31
|
-
@tuple
|
32
|
-
end
|
33
|
-
|
34
27
|
# @param input [Array] the result of {#coerce_tuple}
|
35
28
|
# @return [self]
|
36
29
|
# @abstract
|
@@ -103,8 +96,14 @@ module Dry
|
|
103
96
|
include Core::ClassAttributes
|
104
97
|
include Types::Type
|
105
98
|
include Types::Builder
|
99
|
+
include Types::Decorator
|
106
100
|
include ClassDecorator
|
107
101
|
extend HookExtendObject
|
102
|
+
|
103
|
+
# @return [@tuple]
|
104
|
+
def type
|
105
|
+
@tuple
|
106
|
+
end
|
108
107
|
end
|
109
108
|
|
110
109
|
# Extracted due to make it possible to use this feature within {Dry::Struct} classes.
|
@@ -128,6 +127,14 @@ module Dry
|
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
130
|
+
def try(input, &block)
|
131
|
+
if input.is_a?(::Array)
|
132
|
+
@tuple.try(input, &block)
|
133
|
+
else
|
134
|
+
super(input, &block)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
131
138
|
def auto_tuple(*keys)
|
132
139
|
keys_order(keys_order | keys)
|
133
140
|
index = schema.keys.map { |t| [t.name, t.type] }.to_h
|