sorbet-runtime 0.5.6519 → 0.5.6539
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/generic.rb +0 -1
- data/lib/types/props/private/setter_factory.rb +60 -2
- 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: 3594dc0c726d2a7189c7544226a6ced4240f4a6df2c18bdae635cc30bb223e7b
|
4
|
+
data.tar.gz: dae60008d7f685ecdf231edefdf0b01b595c597c6ae646e7ba7070eada079fa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519bf1b1c4f04792d88c817a9bb3a213b01e783a96597e1e328a8a5c9736e78ff7a0a93ef31d56787fd9468d09980e4670edffcd71f59ff299cc7a09a80a714b
|
7
|
+
data.tar.gz: 0150d316fb26d07fd0693d3b948dfaa6fe1979053dc12f9811c5c9c6d29b711affaa3e6be16a34a08fd6abf5a1db816b4872b7b655895353cdf65094f7e0ad5c
|
data/lib/types/generic.rb
CHANGED
@@ -34,9 +34,40 @@ module T::Props
|
|
34
34
|
# Use separate methods in order to ensure that we only close over necessary
|
35
35
|
# variables
|
36
36
|
if !T::Props::Utils.need_nil_write_check?(rules) || has_explicit_nil_default
|
37
|
-
|
37
|
+
if validate.nil? && non_nil_type.is_a?(T::Types::Simple)
|
38
|
+
simple_nilable_proc(prop, accessor_key, non_nil_type.raw_type, klass)
|
39
|
+
else
|
40
|
+
nilable_proc(prop, accessor_key, non_nil_type, klass, validate)
|
41
|
+
end
|
38
42
|
else
|
39
|
-
|
43
|
+
if validate.nil? && non_nil_type.is_a?(T::Types::Simple)
|
44
|
+
simple_non_nil_proc(prop, accessor_key, non_nil_type.raw_type, klass)
|
45
|
+
else
|
46
|
+
non_nil_proc(prop, accessor_key, non_nil_type, klass, validate)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
sig do
|
52
|
+
params(
|
53
|
+
prop: Symbol,
|
54
|
+
accessor_key: Symbol,
|
55
|
+
non_nil_type: Module,
|
56
|
+
klass: T.all(Module, T::Props::ClassMethods),
|
57
|
+
)
|
58
|
+
.returns(SetterProc)
|
59
|
+
end
|
60
|
+
private_class_method def self.simple_non_nil_proc(prop, accessor_key, non_nil_type, klass)
|
61
|
+
proc do |val|
|
62
|
+
unless val.is_a?(non_nil_type)
|
63
|
+
T::Props::Private::SetterFactory.raise_pretty_error(
|
64
|
+
klass,
|
65
|
+
prop,
|
66
|
+
T::Utils.coerce(non_nil_type),
|
67
|
+
val,
|
68
|
+
)
|
69
|
+
end
|
70
|
+
instance_variable_set(accessor_key, val)
|
40
71
|
end
|
41
72
|
end
|
42
73
|
|
@@ -71,6 +102,33 @@ module T::Props
|
|
71
102
|
end
|
72
103
|
end
|
73
104
|
|
105
|
+
sig do
|
106
|
+
params(
|
107
|
+
prop: Symbol,
|
108
|
+
accessor_key: Symbol,
|
109
|
+
non_nil_type: Module,
|
110
|
+
klass: T.all(Module, T::Props::ClassMethods),
|
111
|
+
)
|
112
|
+
.returns(SetterProc)
|
113
|
+
end
|
114
|
+
private_class_method def self.simple_nilable_proc(prop, accessor_key, non_nil_type, klass)
|
115
|
+
proc do |val|
|
116
|
+
if val.nil?
|
117
|
+
instance_variable_set(accessor_key, nil)
|
118
|
+
elsif val.is_a?(non_nil_type)
|
119
|
+
instance_variable_set(accessor_key, val)
|
120
|
+
else
|
121
|
+
T::Props::Private::SetterFactory.raise_pretty_error(
|
122
|
+
klass,
|
123
|
+
prop,
|
124
|
+
T::Utils.coerce(non_nil_type),
|
125
|
+
val,
|
126
|
+
)
|
127
|
+
instance_variable_set(accessor_key, val)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
74
132
|
sig do
|
75
133
|
params(
|
76
134
|
prop: Symbol,
|
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.6539
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|