Closed amomchilov closed 1 month ago
@ipvalverde Nice catch. I lost it somehow, but was able to revive it back from my editor's local history.
Can you have a look and review? Cheers
I ran these changes on core (cherry-picked in isolation, on top of the v0.14.3
version that core is currently using), and it type-checks without any changes needed:
https://github.com/Shopify/shopify/commit/36d05ee84d0084e452f644d2b07e01eb54795a8a
Motivation
Closes #1910
Implementation
Decide to refactor the
#type_for
method to take the wholeActiveRecord::TypedStore::Field
object, instead of just itstype_sym
, because I would have needed to also pass infield.array
. This way it can just access what it needs.This has the nice benefit of moving the
if field.null
responsibility out of thedecorate
method.Tests
I added tests for both
array: true, null: true
andarray: true, null: false
. I didn't assert the type of all the methods (since they're mostly the same), just the getter/setter (just like how other tests check them).