sorbet-runtime 0.5.5449 → 0.5.5450
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/decorator.rb +7 -123
- data/lib/types/props/private/setter_factory.rb +4 -4
- 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: 1f4d38cdc92ad119edc8fd747604709663498efcfffe888e319bf270f794434f
|
4
|
+
data.tar.gz: cb898bce41d722ffbff96a7b5c072b9154ec8d67b140fa1caef784ed51d012ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cfdb84172a2be679cde10aac3383e73480a78363b0db51f62f9241b0445d3826b0b012676ebb5818f7b1182835774d489f0b4a248c058db9b0005be7a719890
|
7
|
+
data.tar.gz: 831f372fd6214c480cec1e73303ad477058151de64873f10d66a69c2a850ee566451dd8a8391cf3d159e8f0ff2eec4f354855412271cbe3554386481d89d5427
|
@@ -343,13 +343,8 @@ class T::Props::Decorator
|
|
343
343
|
prop_validate_definition!(name, cls, rules, type_object)
|
344
344
|
|
345
345
|
# Retrive the possible underlying object with T.nilable.
|
346
|
-
underlying_type_object = T::Utils::Nilable.get_underlying_type_object(type_object)
|
347
346
|
type = T::Utils::Nilable.get_underlying_type(type)
|
348
347
|
|
349
|
-
array_subdoc_type = array_subdoc_type(underlying_type_object)
|
350
|
-
hash_value_subdoc_type = hash_value_subdoc_type(underlying_type_object)
|
351
|
-
hash_key_custom_type = hash_key_custom_type(underlying_type_object)
|
352
|
-
|
353
348
|
sensitivity_and_pii = {sensitivity: rules[:sensitivity]}
|
354
349
|
if defined?(Opus) && defined?(Opus::Sensitivity) && defined?(Opus::Sensitivity::Utils)
|
355
350
|
sensitivity_and_pii = Opus::Sensitivity::Utils.normalize_sensitivity_and_pii_annotation(sensitivity_and_pii)
|
@@ -367,27 +362,11 @@ class T::Props::Decorator
|
|
367
362
|
end
|
368
363
|
end
|
369
364
|
|
370
|
-
needs_clone =
|
371
|
-
if cls <= Array || cls <= Hash || cls <= Set
|
372
|
-
shallow_clone_ok(underlying_type_object) ? :shallow : true
|
373
|
-
else
|
374
|
-
false
|
375
|
-
end
|
376
|
-
|
377
365
|
rules = rules.merge(
|
378
366
|
# TODO: The type of this element is confusing. We should refactor so that
|
379
367
|
# it can be always `type_object` (a PropType) or always `cls` (a Module)
|
380
368
|
type: type,
|
381
|
-
# These are precomputed for performance
|
382
|
-
# TODO: A lot of these are only needed by T::Props::Serializable or T::Struct
|
383
|
-
# and can/should be moved accordingly.
|
384
|
-
type_is_custom_type: cls.singleton_class < T::Props::CustomType,
|
385
|
-
type_is_serializable: cls < T::Props::Serializable,
|
386
|
-
type_is_array_of_serializable: !array_subdoc_type.nil?,
|
387
|
-
type_is_hash_of_serializable_values: !hash_value_subdoc_type.nil?,
|
388
|
-
type_is_hash_of_custom_type_keys: !hash_key_custom_type.nil?,
|
389
369
|
type_object: type_object,
|
390
|
-
type_needs_clone: needs_clone,
|
391
370
|
accessor_key: "@#{name}".to_sym,
|
392
371
|
sensitivity: sensitivity_and_pii[:sensitivity],
|
393
372
|
pii: sensitivity_and_pii[:pii],
|
@@ -397,26 +376,13 @@ class T::Props::Decorator
|
|
397
376
|
|
398
377
|
validate_not_missing_sensitivity(name, rules)
|
399
378
|
|
400
|
-
# for backcompat
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
if rules[:type_is_serializable]
|
408
|
-
rules[:serializable_subtype] = cls
|
409
|
-
elsif array_subdoc_type
|
410
|
-
rules[:serializable_subtype] = array_subdoc_type
|
411
|
-
elsif hash_value_subdoc_type && hash_key_custom_type
|
412
|
-
rules[:serializable_subtype] = {
|
413
|
-
keys: hash_key_custom_type,
|
414
|
-
values: hash_value_subdoc_type,
|
415
|
-
}
|
416
|
-
elsif hash_value_subdoc_type
|
417
|
-
rules[:serializable_subtype] = hash_value_subdoc_type
|
418
|
-
elsif hash_key_custom_type
|
419
|
-
rules[:serializable_subtype] = hash_key_custom_type
|
379
|
+
# for backcompat (the `:array` key is deprecated but because the name is
|
380
|
+
# so generic it's really hard to be sure it's not being relied on anymore)
|
381
|
+
if type.is_a?(T::Types::TypedArray)
|
382
|
+
inner = T::Utils::Nilable.get_underlying_type(type.type)
|
383
|
+
if inner.is_a?(Module)
|
384
|
+
rules[:array] = inner
|
385
|
+
end
|
420
386
|
end
|
421
387
|
|
422
388
|
rules[:setter_proc] = T::Props::Private::SetterFactory.build_setter_proc(@class, name, rules).freeze
|
@@ -462,88 +428,6 @@ class T::Props::Decorator
|
|
462
428
|
end
|
463
429
|
end
|
464
430
|
|
465
|
-
# returns the subdoc of the array type, or nil if it's not a Document type
|
466
|
-
#
|
467
|
-
# checked(:never) - Typechecks internally
|
468
|
-
sig do
|
469
|
-
params(type: PropType)
|
470
|
-
.returns(T.nilable(Module))
|
471
|
-
.checked(:never)
|
472
|
-
end
|
473
|
-
private def array_subdoc_type(type)
|
474
|
-
if type.is_a?(T::Types::TypedArray)
|
475
|
-
el_type = T::Utils.unwrap_nilable(type.type) || type.type
|
476
|
-
|
477
|
-
if el_type.is_a?(T::Types::Simple) &&
|
478
|
-
(el_type.raw_type < T::Props::Serializable || el_type.raw_type.is_a?(T::Props::CustomType))
|
479
|
-
return el_type.raw_type
|
480
|
-
end
|
481
|
-
end
|
482
|
-
|
483
|
-
nil
|
484
|
-
end
|
485
|
-
|
486
|
-
# returns the subdoc of the hash value type, or nil if it's not a Document type
|
487
|
-
#
|
488
|
-
# checked(:never) - Typechecks internally
|
489
|
-
sig do
|
490
|
-
params(type: PropType)
|
491
|
-
.returns(T.nilable(Module))
|
492
|
-
.checked(:never)
|
493
|
-
end
|
494
|
-
private def hash_value_subdoc_type(type)
|
495
|
-
if type.is_a?(T::Types::TypedHash)
|
496
|
-
values_type = T::Utils.unwrap_nilable(type.values) || type.values
|
497
|
-
|
498
|
-
if values_type.is_a?(T::Types::Simple) &&
|
499
|
-
(values_type.raw_type < T::Props::Serializable || values_type.raw_type.is_a?(T::Props::CustomType))
|
500
|
-
return values_type.raw_type
|
501
|
-
end
|
502
|
-
end
|
503
|
-
|
504
|
-
nil
|
505
|
-
end
|
506
|
-
|
507
|
-
# returns the type of the hash key, or nil. Any CustomType could be a key, but we only expect T::Enum right now.
|
508
|
-
#
|
509
|
-
# checked(:never) - Typechecks internally
|
510
|
-
sig do
|
511
|
-
params(type: PropType)
|
512
|
-
.returns(T.nilable(Module))
|
513
|
-
.checked(:never)
|
514
|
-
end
|
515
|
-
private def hash_key_custom_type(type)
|
516
|
-
if type.is_a?(T::Types::TypedHash)
|
517
|
-
keys_type = T::Utils.unwrap_nilable(type.keys) || type.keys
|
518
|
-
|
519
|
-
if keys_type.is_a?(T::Types::Simple) && keys_type.raw_type.is_a?(T::Props::CustomType)
|
520
|
-
return keys_type.raw_type
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
|
-
nil
|
525
|
-
end
|
526
|
-
|
527
|
-
# From T::Props::Utils.deep_clone_object, plus String
|
528
|
-
TYPES_NOT_NEEDING_CLONE = T.let([TrueClass, FalseClass, NilClass, Symbol, String, Numeric], T::Array[Module])
|
529
|
-
|
530
|
-
# checked(:never) - Typechecks internally
|
531
|
-
sig {params(type: PropType).returns(T.nilable(T::Boolean)).checked(:never)}
|
532
|
-
private def shallow_clone_ok(type)
|
533
|
-
inner_type =
|
534
|
-
if type.is_a?(T::Types::TypedArray)
|
535
|
-
type.type
|
536
|
-
elsif type.is_a?(T::Types::TypedSet)
|
537
|
-
type.type
|
538
|
-
elsif type.is_a?(T::Types::TypedHash)
|
539
|
-
type.values
|
540
|
-
end
|
541
|
-
|
542
|
-
inner_type.is_a?(T::Types::Simple) && TYPES_NOT_NEEDING_CLONE.any? do |cls|
|
543
|
-
inner_type.raw_type <= cls
|
544
|
-
end
|
545
|
-
end
|
546
|
-
|
547
431
|
sig do
|
548
432
|
params(type: PropTypeOrClass, array: T.untyped, enum: T.untyped)
|
549
433
|
.returns(T::Types::Base)
|
@@ -26,11 +26,11 @@ module T::Props
|
|
26
26
|
# `valid?` on it won't work as expected), so unwrap any T.nilable and
|
27
27
|
# do a check manually. (Note this hack does not fix custom types as
|
28
28
|
# collection elements.)
|
29
|
-
non_nil_type =
|
30
|
-
|
31
|
-
|
32
|
-
T::Utils::Nilable.get_underlying_type_object(rules.fetch(:type_object))
|
29
|
+
non_nil_type = T::Utils::Nilable.get_underlying_type_object(rules.fetch(:type_object))
|
30
|
+
if non_nil_type.is_a?(T::Types::Simple) && non_nil_type.raw_type.singleton_class < T::Props::CustomType
|
31
|
+
non_nil_type = non_nil_type.raw_type
|
33
32
|
end
|
33
|
+
|
34
34
|
accessor_key = rules.fetch(:accessor_key)
|
35
35
|
validate = rules[:setter_validate]
|
36
36
|
|
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.5450
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|