sorbet-runtime 0.5.5403 → 0.5.5406

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/types/props/decorator.rb +28 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f473428349c55b787d0d32060bf8a78448adf9a1133f0c8e20f817b83e7d4c58
4
- data.tar.gz: 434b145981f510ef0148a270ec5227fcfb8d1c741e4e9eb26ebf0ebc1e665c96
3
+ metadata.gz: eae0cc4b7fdb52047e84a290e7b7cd213cdc65e695367520f0b6f20812ae2a11
4
+ data.tar.gz: 760c82af2b52574b6de71ac9871e34b6086cd0938d285e84840ded2deabf370b
5
5
  SHA512:
6
- metadata.gz: 9de7bf33a67fb9f5dbdb430138eae9ebbcfe2ecda211419728948f7f8095cc26ca97927886fc23378a24da62e0324480101e4ea9a153e4b0e45e3b97fda3cd44
7
- data.tar.gz: 15b30b2ea60102d219e53d774aea7bfc56277bee5616a5a24f3bb47a774a6ec8e9cf02c6addadc390e8a40cec86619e69aa319f0b8086ad2236209e895405b62
6
+ metadata.gz: fe8068bf43f3a19b01697898272ac24fe375a908f72aeeaffc57be2863bfde26ed19f5ce2d9b7da7d2de8d1d4b3f9805685507ef1020035e1f3339a7406407f9
7
+ data.tar.gz: 1fe68bcff353ed2ba795b315382fbb3262664c87134f6a68bb34ff6e375c9334efbb4fb20df31677135fd1fc92e8ae2b7210be0bd1f99f2c5eeb70b8fb5d6578
@@ -429,7 +429,7 @@ class T::Props::Decorator
429
429
  end
430
430
 
431
431
  handle_foreign_option(name, cls, rules, rules[:foreign]) if rules[:foreign]
432
- handle_foreign_hint_only_option(cls, rules[:foreign_hint_only]) if rules[:foreign_hint_only]
432
+ handle_foreign_hint_only_option(name, cls, rules[:foreign_hint_only]) if rules[:foreign_hint_only]
433
433
  handle_redaction_option(name, rules[:redaction]) if rules[:redaction]
434
434
  end
435
435
 
@@ -636,12 +636,13 @@ class T::Props::Decorator
636
636
 
637
637
  sig do
638
638
  params(
639
+ prop_name: Symbol,
639
640
  prop_cls: Module,
640
641
  foreign_hint_only: T.untyped,
641
642
  )
642
643
  .void
643
644
  end
644
- private def handle_foreign_hint_only_option(prop_cls, foreign_hint_only)
645
+ private def handle_foreign_hint_only_option(prop_name, prop_cls, foreign_hint_only)
645
646
  if ![String, Array].include?(prop_cls) && !(prop_cls.is_a?(T::Props::CustomType))
646
647
  raise ArgumentError.new(
647
648
  "`foreign_hint_only` can only be used with String or Array prop types"
@@ -652,6 +653,21 @@ class T::Props::Decorator
652
653
  :foreign_hint_only, foreign_hint_only,
653
654
  valid_type_msg: "an individual or array of a model class, or a Proc returning such."
654
655
  )
656
+
657
+ unless foreign_hint_only.is_a?(Proc)
658
+ T::Configuration.soft_assert_handler(<<~MESSAGE, storytime: {prop: prop_name, value: foreign_hint_only}, notify: 'jerry')
659
+ Please use a Proc that returns a model class instead of the model class itself as the argument to `foreign_hint_only`. In other words:
660
+
661
+ instead of `prop :foo, String, foreign_hint_only: FooModel`
662
+ use `prop :foo, String, foreign_hint_only: -> {FooModel}`
663
+
664
+ OR
665
+
666
+ instead of `prop :foo, String, foreign_hint_only: [FooModel, BarModel]`
667
+ use `prop :foo, String, foreign_hint_only: -> {[FooModel, BarModel]}`
668
+
669
+ MESSAGE
670
+ end
655
671
  end
656
672
 
657
673
  # checked(:never) - Rules hash is expensive to check
@@ -745,6 +761,16 @@ class T::Props::Decorator
745
761
  )
746
762
  end
747
763
 
764
+ unless foreign.is_a?(Proc)
765
+ T::Configuration.soft_assert_handler(<<~MESSAGE, storytime: {prop: prop_name, value: foreign}, notify: 'jerry')
766
+ Please use a Proc that returns a model class instead of the model class itself as the argument to `foreign`. In other words:
767
+
768
+ instead of `prop :foo, String, foreign: FooModel`
769
+ use `prop :foo, String, foreign: -> {FooModel}`
770
+
771
+ MESSAGE
772
+ end
773
+
748
774
  define_foreign_method(prop_name, rules, foreign)
749
775
  end
750
776
 
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.5403
4
+ version: 0.5.5406
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-28 00:00:00.000000000 Z
11
+ date: 2020-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest