sorbet-coerce 0.0.1 → 0.1.0

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: 136d8069b4fcb9d8e819c025f5085ca957ff17b5a620ccb0942d89f406bd8564
4
- data.tar.gz: 7b2128b6db027094fe762cd378432b9788648bb53c561e8c3dc1a85255214fed
3
+ metadata.gz: b782e5a5b86602bca93180834ff7ed40f1fc4f05b112aeff37bc7a64963e9f3a
4
+ data.tar.gz: cae4b199fe1f9f504641101995a55b2e56e16f8260da8a0b2289f59544fc8af3
5
5
  SHA512:
6
- metadata.gz: 4d0926cd6be851d127e9cc84be9b1a3c6130eb15f2dd6416bd37fe02dea1296159bc693dc78281148232a23b48d6aae73a9174af8bf95d43f8e7df9c7bae4e4f
7
- data.tar.gz: 2338760290ceee4329c15ae879bd6c5ec7a27a0e80dfd047abefb7c14f85def8d5a32e2174193f9ac279d1971b1cdc635073d6517ed2b9cfd6f81e04b122f121
6
+ metadata.gz: d9523a1ce9514a8203377b133b1f56f56c23e241bc01f47018588d11d096a5e1ba87ccb6b4372faea3f6efcf4384478241f1da198739bd0972943b187dd9c00e
7
+ data.tar.gz: 694ac86c81038acac9b8289dd5ebda5934c1f0f42d0c4a8a4f4d83bd01a58af272c61e95dedf5ff42da0b2a2aba4e5c5a1562d21006c0b51532b5a59f2f76851
@@ -1,6 +1,9 @@
1
1
  # typed: strict
2
2
  require 'safe_type'
3
3
  require 'sorbet-runtime'
4
+ require 'polyfill'
5
+
6
+ using Polyfill(Hash: %w[#slice])
4
7
 
5
8
  module T; end
6
9
 
data/lib/sorbet-coerce.rb CHANGED
@@ -11,9 +11,11 @@ module T
11
11
  define_method(:to_s) { "#{name}#[#{type.to_s}]" }
12
12
 
13
13
  define_method(:from) do |args|
14
- T.send('let', send('_convert', args, type), type)
15
- rescue TypeError
16
- raise CoercionError.new(args, type)
14
+ begin
15
+ T.send('let', send('_convert', args, type), type)
16
+ rescue TypeError
17
+ raise CoercionError.new(args, type)
18
+ end
17
19
  end
18
20
  end
19
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-coerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chan Zuckerberg Initiative
@@ -130,5 +130,6 @@ rubyforge_project:
130
130
  rubygems_version: 2.7.9
131
131
  signing_key:
132
132
  specification_version: 4
133
- summary: Type coercion with Sorbet
133
+ summary: A type coercion lib works with Sorbet's static type checker and type definitions;
134
+ raises an error if the coercion fails.
134
135
  test_files: []