sorbet-runtime 0.4.4987 → 0.4.4992
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/enum.rb +14 -5
- 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: 9bb5af2209e2fc4f71cb9b05f384c1be3a5cd285323ffd49c1f4ab3e87be833f
|
|
4
|
+
data.tar.gz: 79717c9a931189459075c571d78358924587c83ac7ff9316c45c385b79ece146
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8afc2c5bd29c610165fefea44ef6b0eb5dc85823f46fc71f87f9e0354b0c7d2159e5f2b32f67a0c8595de8331e7b8de0face291a74322e09d8f20635f6565737
|
|
7
|
+
data.tar.gz: ab6582870d2b05e6c4979a6cea406b45c10808d0b1719b8c23a2231e015042c53eddf0d82228e2084435efc2c1acdedbe23d6743a5c16e10452b0a8787fc2a20
|
data/lib/types/enum.rb
CHANGED
|
@@ -57,6 +57,19 @@ class T::Enum
|
|
|
57
57
|
@values
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
+
# Convert from serialized value to enum instance
|
|
61
|
+
#
|
|
62
|
+
# Note: It would have been nice to make this method final before people started overriding it.
|
|
63
|
+
# Note: Failed CriticalMethodsNoRuntimeTypingTest
|
|
64
|
+
sig {params(serialized_val: SerializedVal).returns(T.nilable(T.experimental_attached_class)).checked(:never)}
|
|
65
|
+
def self.try_deserialize(serialized_val)
|
|
66
|
+
if @mapping.nil?
|
|
67
|
+
raise "Attempting to access serialization map of #{self.class} before it has been initialized." \
|
|
68
|
+
" Enums are not initialized until the 'enums do' block they are defined in has finished running."
|
|
69
|
+
end
|
|
70
|
+
@mapping[serialized_val]
|
|
71
|
+
end
|
|
72
|
+
|
|
60
73
|
# Convert from serialized value to enum instance.
|
|
61
74
|
#
|
|
62
75
|
# Note: It would have been nice to make this method final before people started overriding it.
|
|
@@ -66,11 +79,7 @@ class T::Enum
|
|
|
66
79
|
# @raise [KeyError] if serialized value does not match any instance.
|
|
67
80
|
sig {overridable.params(serialized_val: SerializedVal).returns(T.experimental_attached_class).checked(:never)}
|
|
68
81
|
def self.from_serialized(serialized_val)
|
|
69
|
-
|
|
70
|
-
raise "Attempting to access serialization map of #{self.class} before it has been initialized." \
|
|
71
|
-
" Enums are not initialized until the 'enums do' block they are defined in has finished running."
|
|
72
|
-
end
|
|
73
|
-
res = @mapping[serialized_val]
|
|
82
|
+
res = try_deserialize(serialized_val)
|
|
74
83
|
if res.nil?
|
|
75
84
|
raise KeyError.new("Enum #{self} key not found: #{serialized_val.inspect}")
|
|
76
85
|
end
|
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.4.
|
|
4
|
+
version: 0.4.4992
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-11-
|
|
11
|
+
date: 2019-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|