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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a36c0a956aee4ce8e78e9585799a20639754d948262415124cdde5785acfdeb5
4
- data.tar.gz: f1df593f23974252f13762fa67bc2890de361b7f7db7f0dd906b1035e89433e6
3
+ metadata.gz: d34429f332f3625d7fb9c544970e62a86494089f3d6c7b0a6feeef2010265fa8
4
+ data.tar.gz: dd1498592e58846f4efc5c6ff8aebc52af283987a68a8147b90001243203754c
5
5
  SHA512:
6
- metadata.gz: 6489cc5e4bf147de9b7f57f178c54468fa656961f30ac252f02c02a5a5bef4569714c7227503b1ae68fefbaa28b947c64159dc9086d8b8cc1726e962b778c38d
7
- data.tar.gz: 8cd9b6d6ed52390e73b7ce3a0a46b320a4acdea86661aae957e8e11bb85e092f280c15df39d214a546f654248f8f646723ca7ea596dda7cafa43771b66d81014
6
+ metadata.gz: 62c95a4a0274384ab82be8d328aee679c3ee1f23a73d4d4cc4ad9a2a4b1dd7ba7aaac9089b3505038096eac49569c80900783a9da2957f9652ded8f1b4a9a788
7
+ data.tar.gz: 811af282b857f9cd8718692df14f9512c80678356b9fd31cc1486e0432431b948dfe7b5ee77de6cdb3d1c22791e104dd1aeb218260d1159d80a5b0da2753066a
@@ -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
- entries = @types.map do |(k, v)|
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 {#{obj.map {|(k, v)| "#{k}: #{v.class}"}.join(', ')}}"
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.9064
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-24 00:00:00.000000000 Z
11
+ date: 2021-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest