sorbet-runtime 0.5.5207 → 0.5.5213
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 +28 -11
- 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: bd7c2c5d45d883ad4e220fc3203d9ef80dc3e8107f9871335db7aaa4c9a9a40f
|
4
|
+
data.tar.gz: 4966f2a48e6c729c45030c5f375ad5f835709349dcc1c8ea7e69a5c242d06293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d73323f743b97181769e7973f3ad3942dec32822ea7e5e04870a5a3639f800cf3a21dd0a34f88ded31a1d22acae114b0e24987110a6cf781c56676cd63a9ee48
|
7
|
+
data.tar.gz: f0a09a571797e982ee13316799c1886824a97a47efc1c795d843740ab1c8990c4af3fe746e22918e24beb7675eab0f09c62f358e0f199cbbc6884e8a5975c238
|
@@ -201,6 +201,9 @@ class T::Props::Decorator
|
|
201
201
|
|
202
202
|
# For performance, don't use named params here.
|
203
203
|
# Passing in rules here is purely a performance optimization.
|
204
|
+
#
|
205
|
+
# Note this path is NOT used by generated getters on instances,
|
206
|
+
# unless `ifunset` is used on the prop, or `prop_get` is overridden.
|
204
207
|
sig do
|
205
208
|
params(
|
206
209
|
instance: DecoratedInstance,
|
@@ -213,15 +216,7 @@ class T::Props::Decorator
|
|
213
216
|
def prop_get(instance, prop, rules=props[prop.to_sym])
|
214
217
|
val = get(instance, prop, rules)
|
215
218
|
|
216
|
-
|
217
|
-
# that `== nil` can return true while `.nil?` returns false. Tests will break in mysterious
|
218
|
-
# ways. A special thanks to Ruby for enabling this type of bug.
|
219
|
-
#
|
220
|
-
# One side effect here is that _if_ a class (like BSON::ByteBuffer) defines ==
|
221
|
-
# in such a way that instances which are not `nil`, ie are not NilClass, nevertheless
|
222
|
-
# are `== nil`, then we will transparently convert such instances to `nil` on read.
|
223
|
-
# Yes, our code relies on this behavior (as of writing). :thisisfine:
|
224
|
-
if val != nil # rubocop:disable Style/NonNilCheck
|
219
|
+
if !val.nil?
|
225
220
|
val
|
226
221
|
else
|
227
222
|
raise NoRulesError.new if !rules
|
@@ -510,8 +505,13 @@ class T::Props::Decorator
|
|
510
505
|
end
|
511
506
|
end
|
512
507
|
|
513
|
-
|
514
|
-
|
508
|
+
if method(:prop_get).owner != T::Props::Decorator || rules.key?(:ifunset)
|
509
|
+
@class.send(:define_method, name) do
|
510
|
+
self.class.decorator.prop_get(self, name, rules)
|
511
|
+
end
|
512
|
+
else
|
513
|
+
# Fast path (~30x faster as of Ruby 2.6)
|
514
|
+
@class.attr_reader(name)
|
515
515
|
end
|
516
516
|
end
|
517
517
|
end
|
@@ -811,6 +811,23 @@ class T::Props::Decorator
|
|
811
811
|
# time. Any class that defines props and also overrides the `decorator_class` method is going
|
812
812
|
# to reach this line before its override take effect, turning it into a no-op.
|
813
813
|
child.decorator.add_prop_definition(name, copied_rules)
|
814
|
+
|
815
|
+
# It's a bit tricky to support `prop_get` hooks added by plugins without
|
816
|
+
# sacrificing the `attr_reader` fast path or clobbering customized getters
|
817
|
+
# defined manually on a child.
|
818
|
+
#
|
819
|
+
# To make this work, we _do_ clobber getters defined on the child, but only if:
|
820
|
+
# (a) it's needed in order to support a `prop_get` hook, and
|
821
|
+
# (b) it's safe because the getter was defined by this file.
|
822
|
+
#
|
823
|
+
unless rules[:without_accessors]
|
824
|
+
if child.decorator.method(:prop_get).owner != method(:prop_get).owner &&
|
825
|
+
child.instance_method(name).source_location.first == __FILE__
|
826
|
+
child.send(:define_method, name) do
|
827
|
+
self.class.decorator.prop_get(self, name, rules)
|
828
|
+
end
|
829
|
+
end
|
830
|
+
end
|
814
831
|
end
|
815
832
|
end
|
816
833
|
|
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.5213
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|