sorbet-runtime 0.5.9064 → 0.5.9088
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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: d34429f332f3625d7fb9c544970e62a86494089f3d6c7b0a6feeef2010265fa8
|
4
|
+
data.tar.gz: dd1498592e58846f4efc5c6ff8aebc52af283987a68a8147b90001243203754c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62c95a4a0274384ab82be8d328aee679c3ee1f23a73d4d4cc4ad9a2a4b1dd7ba7aaac9089b3505038096eac49569c80900783a9da2957f9652ded8f1b4a9a788
|
7
|
+
data.tar.gz: 811af282b857f9cd8718692df14f9512c80678356b9fd31cc1486e0432431b948dfe7b5ee77de6cdb3d1c22791e104dd1aeb218260d1159d80a5b0da2753066a
|
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.9088
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|