@@ -6,18 +6,25 @@ module Type
66 # @abstract
77 class BaseModel
88 extend FinchAPI ::Internal ::Type ::Converter
9+ extend FinchAPI ::Internal ::Util ::SorbetRuntimeSupport
910
1011 class << self
1112 # @api private
1213 #
1314 # Assumes superclass fields are totally defined before fields are accessed /
1415 # defined on subclasses.
1516 #
16- # @return [Hash{Symbol=>Hash{Symbol=>Object}}]
17- def known_fields
18- @known_fields ||= ( self < FinchAPI ::Internal ::Type ::BaseModel ? superclass . known_fields . dup : { } )
17+ # @param child [Class<FinchAPI::Internal::Type::BaseModel>]
18+ def inherited ( child )
19+ super
20+ child . known_fields . replace ( known_fields . dup )
1921 end
2022
23+ # @api private
24+ #
25+ # @return [Hash{Symbol=>Hash{Symbol=>Object}}]
26+ def known_fields = @known_fields ||= { }
27+
2128 # @api private
2229 #
2330 # @return [Hash{Symbol=>Hash{Symbol=>Object}}]
@@ -206,7 +213,7 @@ class << self
206213 #
207214 # @option state [Integer] :branched
208215 #
209- # @return [FinchAPI::Internal::Type::BaseModel , Object]
216+ # @return [self , Object]
210217 def coerce ( value , state :)
211218 exactness = state . fetch ( :exactness )
212219
@@ -265,7 +272,7 @@ def coerce(value, state:)
265272
266273 # @api private
267274 #
268- # @param value [FinchAPI::Internal::Type::BaseModel , Object]
275+ # @param value [self , Object]
269276 #
270277 # @param state [Hash{Symbol=>Object}] .
271278 #
@@ -431,6 +438,10 @@ def to_s = self.class.walk(@data).to_s
431438 #
432439 # @return [String]
433440 def inspect = "#<#{ self . class } :0x#{ object_id . to_s ( 16 ) } #{ self } >"
441+
442+ define_sorbet_constant! ( :KnownField ) do
443+ T . type_alias { { mode : T . nilable ( Symbol ) , required : T ::Boolean , nilable : T ::Boolean } }
444+ end
434445 end
435446 end
436447 end
0 commit comments