sorbet-runtime 0.5.5295 → 0.5.5308

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: 42a2b7d38508776778731f4b8648bce4091f05fe2b00088811b16aaf749a5a78
4
- data.tar.gz: cc662c909019bcf4892de529e719c193541846aa2fac45a39267583aaadf9fba
3
+ metadata.gz: 5a5e10d6356cbd45178246b2edd1e4d951af88b12baf3ea0ff1001357aa1256a
4
+ data.tar.gz: 2bfcf37676d14b688c54d98f8ca0d059bb0417be8f29263309b3929c826ba0a4
5
5
  SHA512:
6
- metadata.gz: 6880d036ff679ae42a57849d16d3ca585e2f797471024b5ddbebb79af331f7c106c3746c640bb466b0f4048a66dee923032f7dd565e67f29f71a9d71baac905f
7
- data.tar.gz: 15fb70fb36c1f68b026847c72140facc1267925299552ce538e3d68d9add992edf878ba45f8fd955617122f1cf7a47b530699df85552e4672dc8c76ae9ed5008
6
+ metadata.gz: 73fb3bfcab64fcd1b83c113b4087feac4e7662e6705a2b98c580be4321018b153ba20a28ad5ebd14d89f8a7cd8ae228f689ab0b35b6b6cc4faa1026cdb27c564
7
+ data.tar.gz: 65bf68c479239a301c7cf8f589630fe45fd697e96d050bc9b56c6004c85ec38af9322220d45d9d4ca9e178515104bb549a7e868b7ec2123009290cbd97d2965f
@@ -91,25 +91,6 @@ class T::Props::Decorator
91
91
 
92
92
  # Accessors
93
93
 
94
- # For performance, don't use named params here.
95
- # Passing in rules here is purely a performance optimization.
96
- #
97
- # checked(:never) - O(prop accesses)
98
- sig do
99
- params(
100
- instance: DecoratedInstance,
101
- prop: T.any(String, Symbol),
102
- rules: T.nilable(Rules)
103
- )
104
- .returns(T.untyped)
105
- .checked(:never)
106
- end
107
- def get(instance, prop, rules=props[prop.to_sym])
108
- # For backwards compatibility, fall back to reconstructing the accessor key
109
- # (though it would probably make more sense to raise in that case).
110
- instance.instance_variable_get(rules ? rules[:accessor_key] : '@' + prop.to_s) # rubocop:disable PrisonGuard/NoLurkyInstanceVariableAccess
111
- end
112
-
113
94
  # Use this to validate that a value will validate for a given prop. Useful for knowing whether a value can be set on a model without setting it.
114
95
  #
115
96
  # checked(:never) - potentially O(prop accesses) depending on usage pattern
@@ -157,20 +138,17 @@ class T::Props::Decorator
157
138
  params(
158
139
  instance: DecoratedInstance,
159
140
  prop: T.any(String, Symbol),
160
- rules: T.nilable(Rules)
141
+ rules: Rules
161
142
  )
162
143
  .returns(T.untyped)
163
144
  .checked(:never)
164
145
  end
165
- def prop_get(instance, prop, rules=props[prop.to_sym])
166
- val = get(instance, prop, rules)
167
-
146
+ def prop_get(instance, prop, rules=prop_rules(prop))
147
+ val = instance.instance_variable_get(rules[:accessor_key])
168
148
  if !val.nil?
169
149
  val
170
150
  else
171
- raise NoRulesError.new if !rules
172
- d = rules[:ifunset]
173
- if d
151
+ if (d = rules[:ifunset])
174
152
  T::Props::Utils.deep_clone_object(d)
175
153
  else
176
154
  nil
@@ -178,6 +156,20 @@ class T::Props::Decorator
178
156
  end
179
157
  end
180
158
 
159
+ sig do
160
+ params(
161
+ instance: DecoratedInstance,
162
+ prop: T.any(String, Symbol),
163
+ rules: Rules
164
+ )
165
+ .returns(T.untyped)
166
+ .checked(:never)
167
+ end
168
+ def prop_get_if_set(instance, prop, rules=prop_rules(prop))
169
+ instance.instance_variable_get(rules[:accessor_key])
170
+ end
171
+ alias_method :get, :prop_get_if_set # Alias for backwards compatibility
172
+
181
173
  # checked(:never) - O(prop accesses)
182
174
  sig do
183
175
  params(
@@ -344,7 +344,7 @@ module T::Props::Serializable::DecoratorMethods
344
344
  private_constant :EMPTY_EXTRA_PROPS
345
345
 
346
346
  def extra_props(instance)
347
- get(instance, '_extra_props') || EMPTY_EXTRA_PROPS
347
+ instance.instance_variable_get(:@_extra_props) || EMPTY_EXTRA_PROPS
348
348
  end
349
349
 
350
350
  # @override T::Props::PrettyPrintable
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.5295
4
+ version: 0.5.5308
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-28 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest