sorbet-runtime 0.5.5835 → 0.5.5841
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/props/constructor.rb +9 -3
- data/lib/types/props/weak_constructor.rb +14 -9
- 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: 02df0e4234d0887f7584ed03f2efd4ceabe7cd2aad902a198617207b02d92a6a
|
4
|
+
data.tar.gz: 3cef81d70c297f03d9b6307c32c7c6b079e120ac5a92681ff371bb3d010205b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e0cb83492e866202da027d8f8a5800a52fb7f0e3e4353952ec0250b28122704ad1bc5317ebd30b388df247d0a353afa239393aeafe3421d100d81a5f5456c81
|
7
|
+
data.tar.gz: 6a8b52a3830af73aec07c37bd6afba1081fbd47fbe0d37601803a1ccd73fa1edd08d9fbb233bb9c0556d81baff8571f791e723e7c84f117622c5fcf42ec91e40
|
@@ -17,11 +17,16 @@ module T::Props::Constructor::DecoratorMethods
|
|
17
17
|
# checked(:never) - O(runtime object construction)
|
18
18
|
sig {params(instance: T::Props::Constructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
|
19
19
|
def construct_props_without_defaults(instance, hash)
|
20
|
-
|
20
|
+
# Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
|
21
|
+
# and therefore allocates for each entry.
|
22
|
+
result = 0
|
23
|
+
@props_without_defaults&.each_pair do |p, setter_proc|
|
21
24
|
begin
|
22
25
|
val = hash[p]
|
23
26
|
instance.instance_exec(val, &setter_proc)
|
24
|
-
val || hash.key?(p)
|
27
|
+
if val || hash.key?(p)
|
28
|
+
result += 1
|
29
|
+
end
|
25
30
|
rescue TypeError, T::Props::InvalidValueError
|
26
31
|
if !hash.key?(p)
|
27
32
|
raise ArgumentError.new("Missing required prop `#{p}` for class `#{instance.class.name}`")
|
@@ -29,6 +34,7 @@ module T::Props::Constructor::DecoratorMethods
|
|
29
34
|
raise
|
30
35
|
end
|
31
36
|
end
|
32
|
-
end
|
37
|
+
end
|
38
|
+
result
|
33
39
|
end
|
34
40
|
end
|
@@ -30,14 +30,16 @@ module T::Props::WeakConstructor::DecoratorMethods
|
|
30
30
|
# checked(:never) - O(runtime object construction)
|
31
31
|
sig {params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
|
32
32
|
def construct_props_without_defaults(instance, hash)
|
33
|
-
|
33
|
+
# Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
|
34
|
+
# and therefore allocates for each entry.
|
35
|
+
result = 0
|
36
|
+
@props_without_defaults&.each_pair do |p, setter_proc|
|
34
37
|
if hash.key?(p)
|
35
38
|
instance.instance_exec(hash[p], &setter_proc)
|
36
|
-
|
37
|
-
else
|
38
|
-
false
|
39
|
+
result += 1
|
39
40
|
end
|
40
|
-
end
|
41
|
+
end
|
42
|
+
result
|
41
43
|
end
|
42
44
|
|
43
45
|
# Set values for all props that have defaults. Use the default if and only if
|
@@ -49,14 +51,17 @@ module T::Props::WeakConstructor::DecoratorMethods
|
|
49
51
|
# checked(:never) - O(runtime object construction)
|
50
52
|
sig {params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
|
51
53
|
def construct_props_with_defaults(instance, hash)
|
52
|
-
|
54
|
+
# Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
|
55
|
+
# and therefore allocates for each entry.
|
56
|
+
result = 0
|
57
|
+
@props_with_defaults&.each_pair do |p, default_struct|
|
53
58
|
if hash.key?(p)
|
54
59
|
instance.instance_exec(hash[p], &default_struct.setter_proc)
|
55
|
-
|
60
|
+
result += 1
|
56
61
|
else
|
57
62
|
default_struct.set_default(instance)
|
58
|
-
false
|
59
63
|
end
|
60
|
-
end
|
64
|
+
end
|
65
|
+
result
|
61
66
|
end
|
62
67
|
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.5.
|
4
|
+
version: 0.5.5841
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|