sorbet-runtime 0.5.9064 → 0.5.9070

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a36c0a956aee4ce8e78e9585799a20639754d948262415124cdde5785acfdeb5
4
- data.tar.gz: f1df593f23974252f13762fa67bc2890de361b7f7db7f0dd906b1035e89433e6
3
+ metadata.gz: 79f359a05e342df8a01ee407b15fa595242e318e994363785efcb10e2c444321
4
+ data.tar.gz: 60ea2f2ba177bb0571bba2b1440e4672e750ed1090559b5eb80ed64dc1227b69
5
5
  SHA512:
6
- metadata.gz: 6489cc5e4bf147de9b7f57f178c54468fa656961f30ac252f02c02a5a5bef4569714c7227503b1ae68fefbaa28b947c64159dc9086d8b8cc1726e962b778c38d
7
- data.tar.gz: 8cd9b6d6ed52390e73b7ce3a0a46b320a4acdea86661aae957e8e11bb85e092f280c15df39d214a546f654248f8f646723ca7ea596dda7cafa43771b66d81014
6
+ metadata.gz: 458e9a4e89ba5c77d6a744a538823964070d1353e33cdd796b5253aff8e10fc878c916e46198f24177004eec0df9ffed1d9d03900e1b150b5f67db844adbc1ba
7
+ data.tar.gz: 33cedb070acefe8a63ba9e23f28253803f29540ce7a739278a18c70d8a1db0a0b55485be8e41afeca22de060bcbdc76e2dcf5b3f5426e4f71cc7455513254450
@@ -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.9070
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-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest