rails-on-sorbet 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,598 @@
1
+ # typed: true
2
+
3
+ class Numeric
4
+ # No number is blank:
5
+ #
6
+ # 1.blank? # => false
7
+ # 0.blank? # => false
8
+ #
9
+ # @return [false]
10
+ #
11
+ # source://activesupport//lib/active_support/core_ext/object/blank.rb#141
12
+ #: -> FalseClass
13
+ def blank?; end
14
+
15
+ # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
16
+ #
17
+ # 2.bytes # => 2
18
+ #
19
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#15
20
+ #: -> self
21
+ def byte; end
22
+
23
+ # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
24
+ #
25
+ # 2.bytes # => 2
26
+ #
27
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#15
28
+ #: -> self
29
+ def bytes; end
30
+
31
+ # Returns a Duration instance matching the number of days provided.
32
+ #
33
+ # 2.days # => 2 days
34
+ #
35
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#37
36
+ #: -> ActiveSupport::Duration
37
+ def day; end
38
+
39
+ # Returns a Duration instance matching the number of days provided.
40
+ #
41
+ # 2.days # => 2 days
42
+ #
43
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#37
44
+ #: -> ActiveSupport::Duration
45
+ def days; end
46
+
47
+ # Returns the number of bytes equivalent to the exabytes provided.
48
+ #
49
+ # 2.exabytes # => 2_305_843_009_213_693_952
50
+ #
51
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#63
52
+ #: -> self
53
+ def exabyte; end
54
+
55
+ # Returns the number of bytes equivalent to the exabytes provided.
56
+ #
57
+ # 2.exabytes # => 2_305_843_009_213_693_952
58
+ #
59
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#63
60
+ #: -> self
61
+ def exabytes; end
62
+
63
+ # Returns a Duration instance matching the number of fortnights provided.
64
+ #
65
+ # 2.fortnights # => 4 weeks
66
+ #
67
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#53
68
+ #: -> ActiveSupport::Duration
69
+ def fortnight; end
70
+
71
+ # Returns a Duration instance matching the number of fortnights provided.
72
+ #
73
+ # 2.fortnights # => 4 weeks
74
+ #
75
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#53
76
+ #: -> ActiveSupport::Duration
77
+ def fortnights; end
78
+
79
+ # Returns the number of bytes equivalent to the gigabytes provided.
80
+ #
81
+ # 2.gigabytes # => 2_147_483_648
82
+ #
83
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#39
84
+ #: -> self
85
+ def gigabyte; end
86
+
87
+ # Returns the number of bytes equivalent to the gigabytes provided.
88
+ #
89
+ # 2.gigabytes # => 2_147_483_648
90
+ #
91
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#39
92
+ #: -> self
93
+ def gigabytes; end
94
+
95
+ # Returns a Duration instance matching the number of hours provided.
96
+ #
97
+ # 2.hours # => 2 hours
98
+ #
99
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#29
100
+ #: -> ActiveSupport::Duration
101
+ def hour; end
102
+
103
+ # Returns a Duration instance matching the number of hours provided.
104
+ #
105
+ # 2.hours # => 2 hours
106
+ #
107
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#29
108
+ #: -> ActiveSupport::Duration
109
+ def hours; end
110
+
111
+ # @return [Boolean]
112
+ #
113
+ # source://activesupport//lib/active_support/core_ext/string/output_safety.rb#13
114
+ #: -> bool
115
+ def html_safe?; end
116
+
117
+ # Returns the number of milliseconds equivalent to the seconds provided.
118
+ # Used with the standard time durations.
119
+ #
120
+ # 2.in_milliseconds # => 2000
121
+ # 1.hour.in_milliseconds # => 3600000
122
+ #
123
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#63
124
+ #: -> self
125
+ def in_milliseconds; end
126
+
127
+ # Returns the number of bytes equivalent to the kilobytes provided.
128
+ #
129
+ # 2.kilobytes # => 2048
130
+ #
131
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#23
132
+ #: -> self
133
+ def kilobyte; end
134
+
135
+ # Returns the number of bytes equivalent to the kilobytes provided.
136
+ #
137
+ # 2.kilobytes # => 2048
138
+ #
139
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#23
140
+ #: -> self
141
+ def kilobytes; end
142
+
143
+ # Returns the number of bytes equivalent to the megabytes provided.
144
+ #
145
+ # 2.megabytes # => 2_097_152
146
+ #
147
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#31
148
+ #: -> self
149
+ def megabyte; end
150
+
151
+ # Returns the number of bytes equivalent to the megabytes provided.
152
+ #
153
+ # 2.megabytes # => 2_097_152
154
+ #
155
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#31
156
+ #: -> self
157
+ def megabytes; end
158
+
159
+ # Returns a Duration instance matching the number of minutes provided.
160
+ #
161
+ # 2.minutes # => 2 minutes
162
+ #
163
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#21
164
+ #: -> ActiveSupport::Duration
165
+ def minute; end
166
+
167
+ # Returns a Duration instance matching the number of minutes provided.
168
+ #
169
+ # 2.minutes # => 2 minutes
170
+ #
171
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#21
172
+ #: -> ActiveSupport::Duration
173
+ def minutes; end
174
+
175
+ # Returns the number of bytes equivalent to the petabytes provided.
176
+ #
177
+ # 2.petabytes # => 2_251_799_813_685_248
178
+ #
179
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#55
180
+ #: -> self
181
+ def petabyte; end
182
+
183
+ # Returns the number of bytes equivalent to the petabytes provided.
184
+ #
185
+ # 2.petabytes # => 2_251_799_813_685_248
186
+ #
187
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#55
188
+ #: -> self
189
+ def petabytes; end
190
+
191
+ # Returns a Duration instance matching the number of seconds provided.
192
+ #
193
+ # 2.seconds # => 2 seconds
194
+ #
195
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#13
196
+ #: -> ActiveSupport::Duration
197
+ def second; end
198
+
199
+ # Returns a Duration instance matching the number of seconds provided.
200
+ #
201
+ # 2.seconds # => 2 seconds
202
+ #
203
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#13
204
+ #: -> ActiveSupport::Duration
205
+ def seconds; end
206
+
207
+ # Returns the number of bytes equivalent to the terabytes provided.
208
+ #
209
+ # 2.terabytes # => 2_199_023_255_552
210
+ #
211
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#47
212
+ #: -> self
213
+ def terabyte; end
214
+
215
+ # Returns the number of bytes equivalent to the terabytes provided.
216
+ #
217
+ # 2.terabytes # => 2_199_023_255_552
218
+ #
219
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#47
220
+ #: -> self
221
+ def terabytes; end
222
+
223
+ # Returns a Duration instance matching the number of weeks provided.
224
+ #
225
+ # 2.weeks # => 2 weeks
226
+ #
227
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#45
228
+ #: -> ActiveSupport::Duration
229
+ def week; end
230
+
231
+ # Returns a Duration instance matching the number of weeks provided.
232
+ #
233
+ # 2.weeks # => 2 weeks
234
+ #
235
+ # source://activesupport//lib/active_support/core_ext/numeric/time.rb#45
236
+ #: -> ActiveSupport::Duration
237
+ def weeks; end
238
+
239
+ # Returns the number of bytes equivalent to the zettabytes provided.
240
+ #
241
+ # 2.zettabytes # => 2_361_183_241_434_822_606_848
242
+ #
243
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#71
244
+ #: -> self
245
+ def zettabyte; end
246
+
247
+ # Returns the number of bytes equivalent to the zettabytes provided.
248
+ #
249
+ # 2.zettabytes # => 2_361_183_241_434_822_606_848
250
+ #
251
+ # source://activesupport//lib/active_support/core_ext/numeric/bytes.rb#71
252
+ #: -> self
253
+ def zettabytes; end
254
+ end
255
+
256
+ # = Active Support \Duration
257
+ #
258
+ # Provides accurate date and time measurements using Date#advance and
259
+ # Time#advance, respectively. It mainly supports the methods on Numeric.
260
+ #
261
+ # 1.month.ago # equivalent to Time.now.advance(months: -1)
262
+ #
263
+ # source://activesupport//lib/active_support/duration.rb#14
264
+ class ActiveSupport::Duration
265
+ # @return [Duration] a new instance of Duration
266
+ #
267
+ # source://activesupport//lib/active_support/duration.rb#224
268
+ def initialize(value, parts, variable = T.unsafe(nil)); end
269
+
270
+ # Returns the modulo of this Duration by another Duration or Numeric.
271
+ # Numeric values are treated as seconds.
272
+ #
273
+ # source://activesupport//lib/active_support/duration.rb#307
274
+ #: (ActiveSupport::Duration | Numeric) -> ActiveSupport::Duration
275
+ def %(other); end
276
+
277
+ # Multiplies this Duration by a Numeric and returns a new Duration.
278
+ #
279
+ # source://activesupport//lib/active_support/duration.rb#282
280
+ #: (ActiveSupport::Duration | Numeric) -> ActiveSupport::Duration
281
+ def *(other); end
282
+
283
+ # Adds another Duration or a Numeric to this Duration. Numeric values
284
+ # are treated as seconds.
285
+ #
286
+ # source://activesupport//lib/active_support/duration.rb#263
287
+ #: (ActiveSupport::Duration | Numeric) -> ActiveSupport::Duration
288
+ def +(other); end
289
+
290
+ # source://activesupport//lib/active_support/duration.rb#321
291
+ #: -> self
292
+ def +@; end
293
+
294
+ # Subtracts another Duration or a Numeric from this Duration. Numeric
295
+ # values are treated as seconds.
296
+ #
297
+ # source://activesupport//lib/active_support/duration.rb#277
298
+ #: (ActiveSupport::Duration | Numeric) -> ActiveSupport::Duration
299
+ def -(other); end
300
+
301
+ # source://activesupport//lib/active_support/duration.rb#317
302
+ #: -> self
303
+ def -@; end
304
+
305
+ # Divides this Duration by a Numeric and returns a new Duration.
306
+ #
307
+ # source://activesupport//lib/active_support/duration.rb#293
308
+ #: (ActiveSupport::Duration | Numeric) -> ActiveSupport::Duration
309
+ def /(other); end
310
+
311
+ # Compares one Duration with another or a Numeric to this Duration.
312
+ # Numeric values are treated as seconds.
313
+ #
314
+ # source://activesupport//lib/active_support/duration.rb#253
315
+ #: (ActiveSupport::Duration | Numeric) -> Integer
316
+ def <=>(other); end
317
+
318
+ #: (ActiveSupport::Duration | Numeric) -> bool
319
+ def <(other); end
320
+ #: (ActiveSupport::Duration | Numeric) -> bool
321
+ def <=(other); end
322
+ #: (ActiveSupport::Duration | Numeric) -> bool
323
+ def >(other); end
324
+ #: (ActiveSupport::Duration | Numeric) -> bool
325
+ def >=(other); end
326
+
327
+ # Returns +true+ if +other+ is also a Duration instance with the
328
+ # same +value+, or if <tt>other == value</tt>.
329
+ #
330
+ # source://activesupport//lib/active_support/duration.rb#336
331
+ #: (top other) -> bool
332
+ def ==(other); end
333
+
334
+ # source://activesupport//lib/active_support/duration.rb#476
335
+ def _parts; end
336
+
337
+ # Calculates a new Time or Date that is as far in the future
338
+ # as this Duration represents.
339
+ #
340
+ # source://activesupport//lib/active_support/duration.rb#431
341
+ #
342
+ #: [D] (?D & Timelike) -> (D & Timelike)
343
+ #: -> ActiveSupport::TimeWithZone
344
+ def after(time = T.unsafe(nil)); end
345
+
346
+ # Calculates a new Time or Date that is as far in the past
347
+ # as this Duration represents.
348
+ #
349
+ # source://activesupport//lib/active_support/duration.rb#439
350
+ #
351
+ #: [D] (?D & Timelike) -> (D & Timelike)
352
+ #: -> ActiveSupport::TimeWithZone
353
+ def ago(time = T.unsafe(nil)); end
354
+
355
+ # source://activesupport//lib/active_support/duration.rb#454
356
+ #: (?T::Hash[Symbol, top]?) -> Integer
357
+ def as_json(options = T.unsafe(nil)); end
358
+
359
+ # Calculates a new Time or Date that is as far in the past
360
+ # as this Duration represents.
361
+ #
362
+ # source://activesupport//lib/active_support/duration.rb#439
363
+ #
364
+ #: [D] (?D & Timelike) -> (D & Timelike)
365
+ #: -> ActiveSupport::TimeWithZone
366
+ def before(time = T.unsafe(nil)); end
367
+
368
+ # source://activesupport//lib/active_support/duration.rb#240
369
+ def coerce(other); end
370
+
371
+ # source://activesupport//lib/active_support/duration.rb#462
372
+ def encode_with(coder); end
373
+
374
+ # Returns +true+ if +other+ is also a Duration instance, which has the
375
+ # same parts as this one.
376
+ #
377
+ # @return [Boolean]
378
+ #
379
+ # source://activesupport//lib/active_support/duration.rb#421
380
+ #
381
+ #: (top) -> bool
382
+ def eql?(other); end
383
+
384
+ # Calculates a new Time or Date that is as far in the future
385
+ # as this Duration represents.
386
+ #
387
+ # source://activesupport//lib/active_support/duration.rb#431
388
+ #
389
+ #: [D] (?D & Timelike) -> (D & Timelike)
390
+ #: -> ActiveSupport::TimeWithZone
391
+ def from_now(time = T.unsafe(nil)); end
392
+
393
+ # source://activesupport//lib/active_support/duration.rb#425
394
+ #
395
+ #: -> Integer
396
+ def hash; end
397
+
398
+ # Returns the amount of days a duration covers as a float
399
+ #
400
+ # 12.hours.in_days # => 0.5
401
+ #
402
+ # source://activesupport//lib/active_support/duration.rb#394
403
+ #
404
+ #: -> Float
405
+ def in_days; end
406
+
407
+ # Returns the amount of hours a duration covers as a float
408
+ #
409
+ # 1.day.in_hours # => 24.0
410
+ #
411
+ # source://activesupport//lib/active_support/duration.rb#387
412
+ #
413
+ #: -> Float
414
+ def in_hours; end
415
+
416
+ # Returns the amount of minutes a duration covers as a float
417
+ #
418
+ # 1.day.in_minutes # => 1440.0
419
+ #
420
+ # source://activesupport//lib/active_support/duration.rb#380
421
+ def in_minutes; end
422
+
423
+ # Returns the amount of months a duration covers as a float
424
+ #
425
+ # 9.weeks.in_months # => 2.07
426
+ #
427
+ # source://activesupport//lib/active_support/duration.rb#408
428
+ #
429
+ #: -> Float
430
+ def in_months; end
431
+
432
+ # Returns the number of seconds that this Duration represents.
433
+ #
434
+ # 1.minute.to_i # => 60
435
+ # 1.hour.to_i # => 3600
436
+ # 1.day.to_i # => 86400
437
+ #
438
+ # Note that this conversion makes some assumptions about the
439
+ # duration of some periods, e.g. months are always 1/12 of year
440
+ # and years are 365.2425 days:
441
+ #
442
+ # # equivalent to (1.year / 12).to_i
443
+ # 1.month.to_i # => 2629746
444
+ #
445
+ # # equivalent to 365.2425.days.to_i
446
+ # 1.year.to_i # => 31556952
447
+ #
448
+ # In such cases, Ruby's core
449
+ # Date[https://ruby-doc.org/stdlib/libdoc/date/rdoc/Date.html] and
450
+ # Time[https://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html] should be used for precision
451
+ # date and time arithmetic.
452
+ #
453
+ # source://activesupport//lib/active_support/duration.rb#372
454
+ #
455
+ #: -> Integer
456
+ def in_seconds; end
457
+
458
+ # Returns the amount of weeks a duration covers as a float
459
+ #
460
+ # 2.months.in_weeks # => 8.696
461
+ #
462
+ # source://activesupport//lib/active_support/duration.rb#401
463
+ #
464
+ #: -> Float
465
+ def in_weeks; end
466
+
467
+ # Returns the amount of years a duration covers as a float
468
+ #
469
+ # 30.days.in_years # => 0.082
470
+ #
471
+ # source://activesupport//lib/active_support/duration.rb#415
472
+ #
473
+ #: -> Float
474
+ def in_years; end
475
+
476
+ # source://activesupport//lib/active_support/duration.rb#458
477
+ def init_with(coder); end
478
+
479
+ # source://activesupport//lib/active_support/duration.rb#445
480
+ #
481
+ #: -> String
482
+ def inspect; end
483
+
484
+ # @return [Boolean]
485
+ #
486
+ # source://activesupport//lib/active_support/duration.rb#330
487
+ #
488
+ #: (Module) -> bool
489
+ def instance_of?(klass); end
490
+
491
+ # @return [Boolean]
492
+ #
493
+ # source://activesupport//lib/active_support/duration.rb#325
494
+ #
495
+ #: (Module) -> bool
496
+ def is_a?(klass); end
497
+
498
+ # Build ISO 8601 Duration string for this duration.
499
+ # The +precision+ parameter can be used to limit seconds' precision of duration.
500
+ #
501
+ # source://activesupport//lib/active_support/duration.rb#468
502
+ #
503
+ #: (?precision: top) -> String
504
+ def iso8601(precision: T.unsafe(nil)); end
505
+
506
+ # @return [Boolean]
507
+ #
508
+ # source://activesupport//lib/active_support/duration.rb#325
509
+ #
510
+ #: (Module) -> bool
511
+ def kind_of?(klass); end
512
+
513
+ # Returns a copy of the parts hash that defines the duration
514
+ #
515
+ # source://activesupport//lib/active_support/duration.rb#236
516
+ #
517
+ #: -> Hash[Symbol, Numeric]
518
+ def parts; end
519
+
520
+ # Calculates a new Time or Date that is as far in the future
521
+ # as this Duration represents.
522
+ #
523
+ # source://activesupport//lib/active_support/duration.rb#431
524
+ #
525
+ #: [D] (?D & Timelike) -> (D & Timelike)
526
+ #: -> ActiveSupport::TimeWithZone
527
+ def since(time = T.unsafe(nil)); end
528
+
529
+ # Returns the number of seconds that this Duration represents.
530
+ #
531
+ # 1.minute.to_i # => 60
532
+ # 1.hour.to_i # => 3600
533
+ # 1.day.to_i # => 86400
534
+ #
535
+ # Note that this conversion makes some assumptions about the
536
+ # duration of some periods, e.g. months are always 1/12 of year
537
+ # and years are 365.2425 days:
538
+ #
539
+ # # equivalent to (1.year / 12).to_i
540
+ # 1.month.to_i # => 2629746
541
+ #
542
+ # # equivalent to 365.2425.days.to_i
543
+ # 1.year.to_i # => 31556952
544
+ #
545
+ # In such cases, Ruby's core
546
+ # Date[https://ruby-doc.org/stdlib/libdoc/date/rdoc/Date.html] and
547
+ # Time[https://ruby-doc.org/stdlib/libdoc/time/rdoc/Time.html] should be used for precision
548
+ # date and time arithmetic.
549
+ #
550
+ # source://activesupport//lib/active_support/duration.rb#372
551
+ #
552
+ #: -> Integer
553
+ def to_i; end
554
+
555
+ # Returns the amount of seconds a duration covers as a string.
556
+ # For more information check to_i method.
557
+ #
558
+ # 1.day.to_s # => "86400"
559
+ #
560
+ # source://activesupport//lib/active_support/duration.rb#348
561
+ #
562
+ #: -> String
563
+ def to_s; end
564
+
565
+ # Calculates a new Time or Date that is as far in the past
566
+ # as this Duration represents.
567
+ #
568
+ # source://activesupport//lib/active_support/duration.rb#439
569
+ #
570
+ #: [D] (?D & Timelike) -> (D & Timelike)
571
+ #: -> ActiveSupport::TimeWithZone
572
+ def until(time = T.unsafe(nil)); end
573
+
574
+ # Returns the value of attribute value.
575
+ #
576
+ # source://activesupport//lib/active_support/duration.rb#133
577
+ #
578
+ #: -> Numeric
579
+ def value; end
580
+ end
581
+
582
+ class DateTime
583
+ class << self
584
+ #: (*untyped) -> instance
585
+ def now(*arg0); end
586
+
587
+ #: (*untyped) -> instance
588
+ def parse(*arg0); end
589
+ end
590
+ end
591
+
592
+ class ActionController::TestCase
593
+ module GeneratedPathHelpersModule; end
594
+ include GeneratedPathHelpersModule
595
+
596
+ module GeneratedUrlHelpersModule; end
597
+ include GeneratedUrlHelpersModule
598
+ end
@@ -0,0 +1,5 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ # Represents time-like types
5
+ Timelike = T.type_alias { T.any(Time, DateTime, ActiveSupport::TimeWithZone) }
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module On
5
+ module Sorbet
6
+ VERSION = '0.1.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sorbet-runtime'
4
+ require_relative 'sorbet/version'
5
+
6
+ module Rails
7
+ module On
8
+ # Main module of the `rails-on-sorbet` gem
9
+ module Sorbet
10
+ end
11
+ end
12
+ end
13
+
14
+ require_relative 'sorbet/active_record_serializer'
15
+ require_relative 'sorbet/alias_association'
16
+ require_relative 'sorbet/current_attributes'
17
+ require_relative 'sorbet/map'
18
+ require_relative 'sorbet/timelike'
@@ -0,0 +1,52 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Tapioca
5
+ module Compilers
6
+ # Creates .rbi files with types for classes that use ActiveRecord serializers
7
+ #: [ConstantType < Class & ::Rails::On::Sorbet::ActiveRecordSerializer]
8
+ class RailsOnSorbetActiveRecordSerializer < Tapioca::Dsl::Compiler
9
+ class << self
10
+ # @override
11
+ #: -> T::Enumerable[Module]
12
+ def gather_constants
13
+ all_classes.select do |klass|
14
+ klass.singleton_class < ::Rails::On::Sorbet::ActiveRecordSerializer
15
+ end
16
+ end
17
+ end
18
+
19
+ # @override
20
+ #: -> void
21
+ def decorate
22
+ root.create_path(constant) do |klass|
23
+ constant._sorbet_serializer_definitions.sort.each do |name, definition|
24
+ return_type = definition.return_type || definition.coder.try(:return_type) || Object
25
+ setter_type = definition.setter_type || definition.coder.try(:setter_type) || return_type
26
+
27
+ return_type_string = "T.nilable(#{return_type})"
28
+ setter_type_string = "T.nilable(#{setter_type})"
29
+ doc = definition.doc
30
+ comments = []
31
+ comments << RBI::Comment.new(doc) if doc
32
+
33
+ klass.create_method(
34
+ name.to_s,
35
+ comments:,
36
+ return_type: return_type_string,
37
+ )
38
+ klass.create_method(
39
+ "#{name}=",
40
+ comments:,
41
+ parameters: [create_param('value', type: setter_type_string)],
42
+ return_type: setter_type_string,
43
+ )
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+ end
52
+ end