sorbet-runtime 0.5.9064 → 0.5.9070
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/private/casts.rb +0 -8
- data/lib/types/types/fixed_hash.rb +16 -10
- data/lib/types/utils.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f359a05e342df8a01ee407b15fa595242e318e994363785efcb10e2c444321
|
4
|
+
data.tar.gz: 60ea2f2ba177bb0571bba2b1440e4672e750ed1090559b5eb80ed64dc1227b69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 458e9a4e89ba5c77d6a744a538823964070d1353e33cdd796b5253aff8e10fc878c916e46198f24177004eec0df9ffed1d9d03900e1b150b5f67db844adbc1ba
|
7
|
+
data.tar.gz: 33cedb070acefe8a63ba9e23f28253803f29540ce7a739278a18c70d8a1db0a0b55485be8e41afeca22de060bcbdc76e2dcf5b3f5426e4f71cc7455513254450
|
data/lib/types/private/casts.rb
CHANGED
@@ -2,14 +2,6 @@
|
|
2
2
|
# typed: false
|
3
3
|
|
4
4
|
module T::Private
|
5
|
-
# Dynamically confirm that `value` is recursively a valid value of
|
6
|
-
# type `type`, including recursively through collections. Note that
|
7
|
-
# in some cases this runtime check can be very expensive, especially
|
8
|
-
# with large collections of objects.
|
9
|
-
def self.check_type_recursive!(value, type)
|
10
|
-
T::Private::Casts.cast_recursive(value, type, cast_method: "T.check_type_recursive!")
|
11
|
-
end
|
12
|
-
|
13
5
|
module Casts
|
14
6
|
def self.cast(value, type, cast_method:)
|
15
7
|
begin
|
@@ -13,15 +13,7 @@ module T::Types
|
|
13
13
|
|
14
14
|
# @override Base
|
15
15
|
def name
|
16
|
-
|
17
|
-
if Symbol === k && ":#{k}" == k.inspect
|
18
|
-
"#{k}: #{v}"
|
19
|
-
else
|
20
|
-
"#{k.inspect} => #{v}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
"{#{entries.join(', ')}}"
|
16
|
+
serialize_hash(@types)
|
25
17
|
end
|
26
18
|
|
27
19
|
# @override Base
|
@@ -59,10 +51,24 @@ module T::Types
|
|
59
51
|
# @override Base
|
60
52
|
def describe_obj(obj)
|
61
53
|
if obj.is_a?(Hash)
|
62
|
-
"type
|
54
|
+
"type #{serialize_hash(obj.transform_values(&:class))}"
|
63
55
|
else
|
64
56
|
super
|
65
57
|
end
|
66
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def serialize_hash(hash)
|
63
|
+
entries = hash.map do |(k, v)|
|
64
|
+
if Symbol === k && ":#{k}" == k.inspect
|
65
|
+
"#{k}: #{v}"
|
66
|
+
else
|
67
|
+
"#{k.inspect} => #{v}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
"{#{entries.join(', ')}}"
|
72
|
+
end
|
67
73
|
end
|
68
74
|
end
|
data/lib/types/utils.rb
CHANGED
@@ -27,6 +27,14 @@ module T::Utils
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
# Dynamically confirm that `value` is recursively a valid value of
|
31
|
+
# type `type`, including recursively through collections. Note that
|
32
|
+
# in some cases this runtime check can be very expensive, especially
|
33
|
+
# with large collections of objects.
|
34
|
+
def self.check_type_recursive!(value, type)
|
35
|
+
T::Private::Casts.cast_recursive(value, type, cast_method: "T.check_type_recursive!")
|
36
|
+
end
|
37
|
+
|
30
38
|
# Returns the set of all methods (public, protected, private) defined on a module or its
|
31
39
|
# ancestors, excluding Object and its ancestors. Overrides of methods from Object (and its
|
32
40
|
# ancestors) are included.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-runtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9070
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|