data_model 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -2
  3. data/.shadowenv.d/.gitignore +2 -0
  4. data/.shadowenv.d/550-ruby.lisp +37 -0
  5. data/.solargraph.yml +22 -0
  6. data/Gemfile.lock +38 -3
  7. data/Rakefile +0 -6
  8. data/Steepfile +27 -0
  9. data/data_model.gemspec +2 -2
  10. data/lib/data_model/boolean.rb +0 -2
  11. data/lib/data_model/builtin/array.rb +32 -25
  12. data/lib/data_model/builtin/big_decimal.rb +15 -14
  13. data/lib/data_model/builtin/boolean.rb +10 -7
  14. data/lib/data_model/builtin/date.rb +15 -12
  15. data/lib/data_model/builtin/float.rb +14 -13
  16. data/lib/data_model/builtin/hash.rb +100 -35
  17. data/lib/data_model/builtin/integer.rb +14 -13
  18. data/lib/data_model/builtin/numeric.rb +35 -0
  19. data/lib/data_model/builtin/object.rb +28 -0
  20. data/lib/data_model/builtin/or.rb +73 -0
  21. data/lib/data_model/builtin/string.rb +15 -16
  22. data/lib/data_model/builtin/symbol.rb +14 -13
  23. data/lib/data_model/builtin/time.rb +17 -14
  24. data/lib/data_model/builtin.rb +9 -9
  25. data/lib/data_model/error.rb +33 -33
  26. data/lib/data_model/errors.rb +107 -143
  27. data/lib/data_model/fixtures/array.rb +22 -9
  28. data/lib/data_model/fixtures/big_decimal.rb +9 -7
  29. data/lib/data_model/fixtures/boolean.rb +5 -5
  30. data/lib/data_model/fixtures/date.rb +13 -11
  31. data/lib/data_model/fixtures/example.rb +7 -7
  32. data/lib/data_model/fixtures/float.rb +9 -7
  33. data/lib/data_model/fixtures/hash.rb +22 -10
  34. data/lib/data_model/fixtures/integer.rb +9 -7
  35. data/lib/data_model/fixtures/numeric.rb +31 -0
  36. data/lib/data_model/fixtures/object.rb +27 -0
  37. data/lib/data_model/fixtures/or.rb +29 -0
  38. data/lib/data_model/fixtures/string.rb +15 -32
  39. data/lib/data_model/fixtures/symbol.rb +9 -7
  40. data/lib/data_model/fixtures/time.rb +13 -11
  41. data/lib/data_model/logging.rb +5 -8
  42. data/lib/data_model/model.rb +11 -8
  43. data/lib/data_model/registry.rb +129 -0
  44. data/lib/data_model/scanner.rb +24 -29
  45. data/lib/data_model/struct.rb +112 -0
  46. data/lib/data_model/testing/minitest.rb +33 -9
  47. data/lib/data_model/testing.rb +0 -2
  48. data/lib/data_model/type.rb +39 -23
  49. data/lib/data_model/version.rb +1 -3
  50. data/lib/data_model.rb +10 -19
  51. metadata +24 -21
  52. data/lib/data_model/type_registry.rb +0 -68
  53. data/sorbet/config +0 -4
  54. data/sorbet/rbi/annotations/rainbow.rbi +0 -269
  55. data/sorbet/rbi/gems/minitest@5.18.0.rbi +0 -1491
  56. data/sorbet/rbi/gems/zeitwerk.rbi +0 -196
  57. data/sorbet/rbi/gems/zeitwerk@2.6.7.rbi +0 -966
  58. data/sorbet/rbi/todo.rbi +0 -5
  59. data/sorbet/tapioca/config.yml +0 -13
  60. data/sorbet/tapioca/require.rb +0 -4
@@ -1,966 +0,0 @@
1
- # typed: false
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `zeitwerk` gem.
5
- # Please instead update this file by running `bin/tapioca gem zeitwerk`.
6
-
7
- # source://zeitwerk//lib/zeitwerk/kernel.rb#3
8
- module Kernel
9
- private
10
-
11
- # source://zeitwerk//lib/zeitwerk/kernel.rb#27
12
- def require(path); end
13
-
14
- class << self
15
- # source://zeitwerk//lib/zeitwerk/kernel.rb#27
16
- def require(path); end
17
- end
18
- end
19
-
20
- # source://zeitwerk//lib/zeitwerk.rb#3
21
- module Zeitwerk
22
- class << self
23
- # This is a dangerous method.
24
- #
25
- # source://zeitwerk//lib/zeitwerk.rb#20
26
- def with_loader; end
27
- end
28
- end
29
-
30
- # source://zeitwerk//lib/zeitwerk/error.rb#4
31
- class Zeitwerk::Error < ::StandardError; end
32
-
33
- # Centralizes the logic for the trace point used to detect the creation of
34
- # explicit namespaces, needed to descend into matching subdirectories right
35
- # after the constant has been defined.
36
- #
37
- # The implementation assumes an explicit namespace is managed by one loader.
38
- # Loaders that reopen namespaces owned by other projects are responsible for
39
- # loading their constant before setup. This is documented.
40
- #
41
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#11
42
- module Zeitwerk::ExplicitNamespace
43
- extend ::Zeitwerk::RealModName
44
-
45
- class << self
46
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#35
47
- def __register(cpath, loader); end
48
-
49
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#53
50
- def __registered?(cpath); end
51
-
52
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#45
53
- def __unregister_loader(loader); end
54
-
55
- private
56
-
57
- # Maps constant paths that correspond to explicit namespaces according to
58
- # the file system, to the loader responsible for them.
59
- #
60
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#20
61
- def cpaths; end
62
-
63
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#58
64
- def disable_tracer_if_unneeded; end
65
-
66
- # Returns the value of attribute mutex.
67
- #
68
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#24
69
- def mutex; end
70
-
71
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#35
72
- def register(cpath, loader); end
73
-
74
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#53
75
- def registered?(cpath); end
76
-
77
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#65
78
- def tracepoint_class_callback(event); end
79
-
80
- # Returns the value of attribute tracer.
81
- #
82
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#28
83
- def tracer; end
84
-
85
- # source://zeitwerk//lib/zeitwerk/explicit_namespace.rb#45
86
- def unregister_loader(loader); end
87
- end
88
- end
89
-
90
- # source://zeitwerk//lib/zeitwerk/gem_inflector.rb#4
91
- class Zeitwerk::GemInflector < ::Zeitwerk::Inflector
92
- # @return [GemInflector] a new instance of GemInflector
93
- #
94
- # source://zeitwerk//lib/zeitwerk/gem_inflector.rb#6
95
- def initialize(root_file); end
96
-
97
- # source://zeitwerk//lib/zeitwerk/gem_inflector.rb#13
98
- def camelize(basename, abspath); end
99
- end
100
-
101
- # @private
102
- #
103
- # source://zeitwerk//lib/zeitwerk/gem_loader.rb#5
104
- class Zeitwerk::GemLoader < ::Zeitwerk::Loader
105
- # @return [GemLoader] a new instance of GemLoader
106
- #
107
- # source://zeitwerk//lib/zeitwerk/gem_loader.rb#17
108
- def initialize(root_file, warn_on_extra_files:); end
109
-
110
- # source://zeitwerk//lib/zeitwerk/gem_loader.rb#30
111
- def setup; end
112
-
113
- private
114
-
115
- # source://zeitwerk//lib/zeitwerk/gem_loader.rb#38
116
- def warn_on_extra_files; end
117
-
118
- class << self
119
- # @private
120
- #
121
- # source://zeitwerk//lib/zeitwerk/gem_loader.rb#12
122
- def _new(root_file, warn_on_extra_files:); end
123
-
124
- private
125
-
126
- def new(*_arg0); end
127
- end
128
- end
129
-
130
- # source://zeitwerk//lib/zeitwerk/inflector.rb#4
131
- class Zeitwerk::Inflector
132
- # Very basic snake case -> camel case conversion.
133
- #
134
- # inflector = Zeitwerk::Inflector.new
135
- # inflector.camelize("post", ...) # => "Post"
136
- # inflector.camelize("users_controller", ...) # => "UsersController"
137
- # inflector.camelize("api", ...) # => "Api"
138
- #
139
- # Takes into account hard-coded mappings configured with `inflect`.
140
- #
141
- # source://zeitwerk//lib/zeitwerk/inflector.rb#15
142
- def camelize(basename, _abspath); end
143
-
144
- # Configures hard-coded inflections:
145
- #
146
- # inflector = Zeitwerk::Inflector.new
147
- # inflector.inflect(
148
- # "html_parser" => "HTMLParser",
149
- # "mysql_adapter" => "MySQLAdapter"
150
- # )
151
- #
152
- # inflector.camelize("html_parser", abspath) # => "HTMLParser"
153
- # inflector.camelize("mysql_adapter", abspath) # => "MySQLAdapter"
154
- # inflector.camelize("users_controller", abspath) # => "UsersController"
155
- #
156
- # source://zeitwerk//lib/zeitwerk/inflector.rb#32
157
- def inflect(inflections); end
158
-
159
- private
160
-
161
- # Hard-coded basename to constant name user maps that override the default
162
- # inflection logic.
163
- #
164
- # source://zeitwerk//lib/zeitwerk/inflector.rb#42
165
- def overrides; end
166
- end
167
-
168
- # This is a private module.
169
- #
170
- # source://zeitwerk//lib/zeitwerk/internal.rb#4
171
- module Zeitwerk::Internal
172
- # source://zeitwerk//lib/zeitwerk/internal.rb#5
173
- def internal(method_name); end
174
- end
175
-
176
- # source://zeitwerk//lib/zeitwerk/loader.rb#6
177
- class Zeitwerk::Loader
178
- include ::Zeitwerk::RealModName
179
- include ::Zeitwerk::Loader::Callbacks
180
- include ::Zeitwerk::Loader::Helpers
181
- include ::Zeitwerk::Loader::Config
182
- include ::Zeitwerk::Loader::EagerLoad
183
- extend ::Zeitwerk::Internal
184
-
185
- # @return [Loader] a new instance of Loader
186
- #
187
- # source://zeitwerk//lib/zeitwerk/loader.rb#98
188
- def initialize; end
189
-
190
- # source://zeitwerk//lib/zeitwerk/loader.rb#42
191
- def __autoloaded_dirs; end
192
-
193
- # source://zeitwerk//lib/zeitwerk/loader.rb#32
194
- def __autoloads; end
195
-
196
- # source://zeitwerk//lib/zeitwerk/loader.rb#76
197
- def __namespace_dirs; end
198
-
199
- # source://zeitwerk//lib/zeitwerk/loader.rb#260
200
- def __shadowed_file?(file); end
201
-
202
- # source://zeitwerk//lib/zeitwerk/loader.rb#87
203
- def __shadowed_files; end
204
-
205
- # source://zeitwerk//lib/zeitwerk/loader.rb#58
206
- def __to_unload; end
207
-
208
- # Unloads all loaded code, and calls setup again so that the loader is able
209
- # to pick any changes in the file system.
210
- #
211
- # This method is not thread-safe, please see how this can be achieved by
212
- # client code in the README of the project.
213
- #
214
- # @raise [Zeitwerk::Error]
215
- #
216
- # source://zeitwerk//lib/zeitwerk/loader.rb#221
217
- def reload; end
218
-
219
- # Sets autoloads in the root namespaces.
220
- #
221
- # source://zeitwerk//lib/zeitwerk/loader.rb#117
222
- def setup; end
223
-
224
- # Removes loaded constants and configured autoloads.
225
- #
226
- # The objects the constants stored are no longer reachable through them. In
227
- # addition, since said objects are normally not referenced from anywhere
228
- # else, they are eligible for garbage collection, which would effectively
229
- # unload them.
230
- #
231
- # This method is public but undocumented. Main interface is `reload`, which
232
- # means `unload` + `setup`. This one is available to be used together with
233
- # `unregister`, which is undocumented too.
234
- #
235
- # source://zeitwerk//lib/zeitwerk/loader.rb#143
236
- def unload; end
237
-
238
- # Says if the given constant path would be unloaded on reload. This
239
- # predicate returns `false` if reloading is disabled.
240
- #
241
- # @return [Boolean]
242
- #
243
- # source://zeitwerk//lib/zeitwerk/loader.rb#235
244
- def unloadable_cpath?(cpath); end
245
-
246
- # Returns an array with the constant paths that would be unloaded on reload.
247
- # This predicate returns an empty array if reloading is disabled.
248
- #
249
- # source://zeitwerk//lib/zeitwerk/loader.rb#243
250
- def unloadable_cpaths; end
251
-
252
- # This is a dangerous method.
253
- #
254
- # source://zeitwerk//lib/zeitwerk/loader.rb#251
255
- def unregister; end
256
-
257
- private
258
-
259
- # source://zeitwerk//lib/zeitwerk/loader.rb#393
260
- def autoload_file(parent, cname, file); end
261
-
262
- # @return [Boolean]
263
- #
264
- # source://zeitwerk//lib/zeitwerk/loader.rb#451
265
- def autoload_path_set_by_me_for?(parent, cname); end
266
-
267
- # source://zeitwerk//lib/zeitwerk/loader.rb#363
268
- def autoload_subdir(parent, cname, subdir); end
269
-
270
- # We keep track of autoloaded directories to remove them from the registry
271
- # at the end of eager loading.
272
- #
273
- # Files are removed as they are autoloaded, but directories need to wait due
274
- # to concurrency (see why in Zeitwerk::Loader::Callbacks#on_dir_autoloaded).
275
- #
276
- # source://zeitwerk//lib/zeitwerk/loader.rb#42
277
- def autoloaded_dirs; end
278
-
279
- # Maps absolute paths for which an autoload has been set ---and not
280
- # executed--- to their corresponding parent class or module and constant
281
- # name.
282
- #
283
- # "/Users/fxn/blog/app/models/user.rb" => [Object, :User],
284
- # "/Users/fxn/blog/app/models/hotel/pricing.rb" => [Hotel, :Pricing]
285
- # ...
286
- #
287
- # source://zeitwerk//lib/zeitwerk/loader.rb#32
288
- def autoloads; end
289
-
290
- # Returns the value of attribute mutex.
291
- #
292
- # source://zeitwerk//lib/zeitwerk/loader.rb#91
293
- def mutex; end
294
-
295
- # Returns the value of attribute mutex2.
296
- #
297
- # source://zeitwerk//lib/zeitwerk/loader.rb#95
298
- def mutex2; end
299
-
300
- # Maps namespace constant paths to their respective directories.
301
- #
302
- # For example, given this mapping:
303
- #
304
- # "Admin" => [
305
- # "/Users/fxn/blog/app/controllers/admin",
306
- # "/Users/fxn/blog/app/models/admin",
307
- # ...
308
- # ]
309
- #
310
- # when `Admin` gets defined we know that it plays the role of a namespace
311
- # and that its children are spread over those directories. We'll visit them
312
- # to set up the corresponding autoloads.
313
- #
314
- # source://zeitwerk//lib/zeitwerk/loader.rb#76
315
- def namespace_dirs; end
316
-
317
- # `dir` is the directory that would have autovivified a namespace. `file` is
318
- # the file where we've found the namespace is explicitly defined.
319
- #
320
- # source://zeitwerk//lib/zeitwerk/loader.rb#419
321
- def promote_namespace_from_implicit_to_explicit(dir:, file:, parent:, cname:); end
322
-
323
- # source://zeitwerk//lib/zeitwerk/loader.rb#465
324
- def raise_if_conflicting_directory(dir); end
325
-
326
- # source://zeitwerk//lib/zeitwerk/loader.rb#460
327
- def register_explicit_namespace(cpath); end
328
-
329
- # source://zeitwerk//lib/zeitwerk/loader.rb#490
330
- def run_on_unload_callbacks(cpath, value, abspath); end
331
-
332
- # source://zeitwerk//lib/zeitwerk/loader.rb#430
333
- def set_autoload(parent, cname, abspath); end
334
-
335
- # source://zeitwerk//lib/zeitwerk/loader.rb#328
336
- def set_autoloads_in_dir(dir, parent); end
337
-
338
- # source://zeitwerk//lib/zeitwerk/loader.rb#260
339
- def shadowed_file?(file); end
340
-
341
- # A shadowed file is a file managed by this loader that is ignored when
342
- # setting autoloads because its matching constant is already taken.
343
- #
344
- # This private set is populated as we descend. For example, if the loader
345
- # has only scanned the top-level, `shadowed_files` does not have shadowed
346
- # files that may exist deep in the project tree yet.
347
- #
348
- # source://zeitwerk//lib/zeitwerk/loader.rb#87
349
- def shadowed_files; end
350
-
351
- # Stores metadata needed for unloading. Its entries look like this:
352
- #
353
- # "Admin::Role" => [".../admin/role.rb", [Admin, :Role]]
354
- #
355
- # The cpath as key helps implementing unloadable_cpath? The file name is
356
- # stored in order to be able to delete it from $LOADED_FEATURES, and the
357
- # pair [Module, Symbol] is used to remove_const the constant from the class
358
- # or module object.
359
- #
360
- # If reloading is enabled, this hash is filled as constants are autoloaded
361
- # or eager loaded. Otherwise, the collection remains empty.
362
- #
363
- # source://zeitwerk//lib/zeitwerk/loader.rb#58
364
- def to_unload; end
365
-
366
- # source://zeitwerk//lib/zeitwerk/loader.rb#497
367
- def unload_autoload(parent, cname); end
368
-
369
- # source://zeitwerk//lib/zeitwerk/loader.rb#503
370
- def unload_cref(parent, cname); end
371
-
372
- class << self
373
- # Returns an array with the absolute paths of the root directories of all
374
- # registered loaders. This is a read-only collection.
375
- #
376
- # source://zeitwerk//lib/zeitwerk/loader.rb#322
377
- def all_dirs; end
378
-
379
- # Returns the value of attribute default_logger.
380
- #
381
- # source://zeitwerk//lib/zeitwerk/loader.rb#268
382
- def default_logger; end
383
-
384
- # Sets the attribute default_logger
385
- #
386
- # @param value the value to set the attribute default_logger to.
387
- #
388
- # source://zeitwerk//lib/zeitwerk/loader.rb#268
389
- def default_logger=(_arg0); end
390
-
391
- # Broadcasts `eager_load` to all loaders. Those that have not been setup
392
- # are skipped.
393
- #
394
- # source://zeitwerk//lib/zeitwerk/loader.rb#294
395
- def eager_load_all; end
396
-
397
- # Broadcasts `eager_load_namespace` to all loaders. Those that have not
398
- # been setup are skipped.
399
- #
400
- # source://zeitwerk//lib/zeitwerk/loader.rb#308
401
- def eager_load_namespace(mod); end
402
-
403
- # This is a shortcut for
404
- #
405
- # require "zeitwerk"
406
- # loader = Zeitwerk::Loader.new
407
- # loader.tag = File.basename(__FILE__, ".rb")
408
- # loader.inflector = Zeitwerk::GemInflector.new(__FILE__)
409
- # loader.push_dir(__dir__)
410
- #
411
- # except that this method returns the same object in subsequent calls from
412
- # the same file, in the unlikely case the gem wants to be able to reload.
413
- #
414
- # This method returns a subclass of Zeitwerk::Loader, but the exact type
415
- # is private, client code can only rely on the interface.
416
- #
417
- # source://zeitwerk//lib/zeitwerk/loader.rb#285
418
- def for_gem(warn_on_extra_files: T.unsafe(nil)); end
419
- end
420
- end
421
-
422
- # source://zeitwerk//lib/zeitwerk/loader/callbacks.rb#3
423
- module Zeitwerk::Loader::Callbacks
424
- include ::Zeitwerk::RealModName
425
-
426
- # Invoked from our decorated Kernel#require when a managed directory is
427
- # autoloaded.
428
- #
429
- # @private
430
- #
431
- # source://zeitwerk//lib/zeitwerk/loader/callbacks.rb#34
432
- def on_dir_autoloaded(dir); end
433
-
434
- # Invoked from our decorated Kernel#require when a managed file is autoloaded.
435
- #
436
- # @private
437
- #
438
- # source://zeitwerk//lib/zeitwerk/loader/callbacks.rb#10
439
- def on_file_autoloaded(file); end
440
-
441
- # Invoked when a class or module is created or reopened, either from the
442
- # tracer or from module autovivification. If the namespace has matching
443
- # subdirectories, we descend into them now.
444
- #
445
- # @private
446
- #
447
- # source://zeitwerk//lib/zeitwerk/loader/callbacks.rb#73
448
- def on_namespace_loaded(namespace); end
449
-
450
- private
451
-
452
- # source://zeitwerk//lib/zeitwerk/loader/callbacks.rb#84
453
- def run_on_load_callbacks(cpath, value, abspath); end
454
- end
455
-
456
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#6
457
- module Zeitwerk::Loader::Config
458
- include ::Zeitwerk::RealModName
459
- extend ::Zeitwerk::Internal
460
-
461
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#86
462
- def initialize; end
463
-
464
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#297
465
- def __ignores?(abspath); end
466
-
467
- def __roots; end
468
-
469
- # Configure directories or glob patterns to be collapsed.
470
- #
471
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#217
472
- def collapse(*glob_patterns); end
473
-
474
- # If `namespaces` is falsey (default), returns an array with the absolute
475
- # paths of the root directories as strings. If truthy, returns a hash table
476
- # instead. Keys are the absolute paths of the root directories as strings,
477
- # values are their corresponding namespaces, class or module objects.
478
- #
479
- # If `ignored` is falsey (default), ignored root directories are filtered out.
480
- #
481
- # These are read-only collections, please add to them with `push_dir`.
482
- #
483
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#157
484
- def dirs(namespaces: T.unsafe(nil), ignored: T.unsafe(nil)); end
485
-
486
- # Let eager load ignore the given files or directories. The constants defined
487
- # in those files are still autoloadable.
488
- #
489
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#199
490
- def do_not_eager_load(*paths); end
491
-
492
- # You need to call this method before setup in order to be able to reload.
493
- # There is no way to undo this, either you want to reload or you don't.
494
- #
495
- # @raise [Zeitwerk::Error]
496
- #
497
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#178
498
- def enable_reloading; end
499
-
500
- # Configure files, directories, or glob patterns to be totally ignored.
501
- #
502
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#206
503
- def ignore(*glob_patterns); end
504
-
505
- # Returns the value of attribute inflector.
506
- #
507
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#11
508
- def inflector; end
509
-
510
- # Sets the attribute inflector
511
- #
512
- # @param value the value to set the attribute inflector to.
513
- #
514
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#11
515
- def inflector=(_arg0); end
516
-
517
- # Logs to `$stdout`, handy shortcut for debugging.
518
- #
519
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#289
520
- def log!; end
521
-
522
- # Returns the value of attribute logger.
523
- #
524
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#14
525
- def logger; end
526
-
527
- # Sets the attribute logger
528
- #
529
- # @param value the value to set the attribute logger to.
530
- #
531
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#14
532
- def logger=(_arg0); end
533
-
534
- # Configure a block to be invoked once a certain constant path is loaded.
535
- # Supports multiple callbacks, and if there are many, they are executed in
536
- # the order in which they were defined.
537
- #
538
- # loader.on_load("SomeApiClient") do |klass, _abspath|
539
- # klass.endpoint = "https://api.dev"
540
- # end
541
- #
542
- # Can also be configured for any constant loaded:
543
- #
544
- # loader.on_load do |cpath, value, abspath|
545
- # # ...
546
- # end
547
- #
548
- # @raise [TypeError]
549
- #
550
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#253
551
- def on_load(cpath = T.unsafe(nil), &block); end
552
-
553
- # Configure a block to be called after setup and on each reload.
554
- # If setup was already done, the block runs immediately.
555
- #
556
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#229
557
- def on_setup(&block); end
558
-
559
- # Configure a block to be invoked right before a certain constant is removed.
560
- # Supports multiple callbacks, and if there are many, they are executed in the
561
- # order in which they were defined.
562
- #
563
- # loader.on_unload("Country") do |klass, _abspath|
564
- # klass.clear_cache
565
- # end
566
- #
567
- # Can also be configured for any removed constant:
568
- #
569
- # loader.on_unload do |cpath, value, abspath|
570
- # # ...
571
- # end
572
- #
573
- # @raise [TypeError]
574
- #
575
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#278
576
- def on_unload(cpath = T.unsafe(nil), &block); end
577
-
578
- # Pushes `path` to the list of root directories.
579
- #
580
- # Raises `Zeitwerk::Error` if `path` does not exist, or if another loader in
581
- # the same process already manages that directory or one of its ascendants or
582
- # descendants.
583
- #
584
- # @raise [Zeitwerk::Error]
585
- #
586
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#111
587
- def push_dir(path, namespace: T.unsafe(nil)); end
588
-
589
- # @return [Boolean]
590
- #
591
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#191
592
- def reloading_enabled?; end
593
-
594
- # Returns the loader's tag.
595
- #
596
- # Implemented as a method instead of via attr_reader for symmetry with the
597
- # writer below.
598
- #
599
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#136
600
- def tag; end
601
-
602
- # Sets a tag for the loader, useful for logging.
603
- #
604
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#143
605
- def tag=(tag); end
606
-
607
- private
608
-
609
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#315
610
- def actual_roots; end
611
-
612
- # @return [Boolean]
613
- #
614
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#340
615
- def collapse?(dir); end
616
-
617
- # The actual collection of absolute directory names at the time the collapse
618
- # glob patterns were expanded. Computed on setup, and recomputed on reload.
619
- #
620
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#57
621
- def collapse_dirs; end
622
-
623
- # Absolute paths of directories or glob patterns to be collapsed.
624
- #
625
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#50
626
- def collapse_glob_patterns; end
627
-
628
- # Absolute paths of files or directories not to be eager loaded.
629
- #
630
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#63
631
- def eager_load_exclusions; end
632
-
633
- # @return [Boolean]
634
- #
635
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#327
636
- def excluded_from_eager_load?(abspath); end
637
-
638
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#350
639
- def expand_glob_patterns(glob_patterns); end
640
-
641
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#345
642
- def expand_paths(paths); end
643
-
644
- # Absolute paths of files, directories, or glob patterns to be totally
645
- # ignored.
646
- #
647
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#36
648
- def ignored_glob_patterns; end
649
-
650
- # @return [Boolean]
651
- #
652
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#310
653
- def ignored_path?(abspath); end
654
-
655
- # The actual collection of absolute file and directory names at the time the
656
- # ignored glob patterns were expanded. Computed on setup, and recomputed on
657
- # reload.
658
- #
659
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#44
660
- def ignored_paths; end
661
-
662
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#297
663
- def ignores?(abspath); end
664
-
665
- # User-oriented callbacks to be fired when a constant is loaded.
666
- #
667
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#76
668
- def on_load_callbacks; end
669
-
670
- # User-oriented callbacks to be fired on setup and on reload.
671
- #
672
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#69
673
- def on_setup_callbacks; end
674
-
675
- # User-oriented callbacks to be fired before constants are removed.
676
- #
677
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#83
678
- def on_unload_callbacks; end
679
-
680
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#362
681
- def recompute_collapse_dirs; end
682
-
683
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#357
684
- def recompute_ignored_paths; end
685
-
686
- # @return [Boolean]
687
- #
688
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#322
689
- def root_dir?(dir); end
690
-
691
- # Absolute paths of the root directories, mapped to their respective root namespaces:
692
- #
693
- # "/Users/fxn/blog/app/channels" => Object,
694
- # "/Users/fxn/blog/app/adapters" => ActiveJob::QueueAdapters,
695
- # ...
696
- #
697
- # Stored in a hash to preserve order, easily handle duplicates, and have a
698
- # fast lookup by directory.
699
- #
700
- # This is a private collection maintained by the loader. The public
701
- # interface for it is `push_dir` and `dirs`.
702
- #
703
- # source://zeitwerk//lib/zeitwerk/loader/config.rb#29
704
- def roots; end
705
- end
706
-
707
- # source://zeitwerk//lib/zeitwerk/loader/eager_load.rb#1
708
- module Zeitwerk::Loader::EagerLoad
709
- # Eager loads all files in the root directories, recursively. Files do not
710
- # need to be in `$LOAD_PATH`, absolute file names are used. Ignored and
711
- # shadowed files are not eager loaded. You can opt-out specifically in
712
- # specific files and directories with `do_not_eager_load`, and that can be
713
- # overridden passing `force: true`.
714
- #
715
- # source://zeitwerk//lib/zeitwerk/loader/eager_load.rb#9
716
- def eager_load(force: T.unsafe(nil)); end
717
-
718
- # @raise [Zeitwerk::SetupRequired]
719
- #
720
- # source://zeitwerk//lib/zeitwerk/loader/eager_load.rb#32
721
- def eager_load_dir(path); end
722
-
723
- # @raise [Zeitwerk::SetupRequired]
724
- #
725
- # source://zeitwerk//lib/zeitwerk/loader/eager_load.rb#72
726
- def eager_load_namespace(mod); end
727
-
728
- # Loads the given Ruby file.
729
- #
730
- # Raises if the argument is ignored, shadowed, or not managed by the receiver.
731
- #
732
- # The method is implemented as `constantize` for files, in a sense, to be able
733
- # to descend orderly and make sure the file is loadable.
734
- #
735
- # @raise [Zeitwerk::Error]
736
- #
737
- # source://zeitwerk//lib/zeitwerk/loader/eager_load.rb#114
738
- def load_file(path); end
739
-
740
- private
741
-
742
- # The caller is responsible for making sure `namespace` is the namespace that
743
- # corresponds to `dir`.
744
- #
745
- # source://zeitwerk//lib/zeitwerk/loader/eager_load.rb#154
746
- def actual_eager_load_dir(dir, namespace, force: T.unsafe(nil)); end
747
-
748
- # In order to invoke this method, the caller has to ensure `child` is a
749
- # strict namespace descendant of `root_namespace`.
750
- #
751
- # source://zeitwerk//lib/zeitwerk/loader/eager_load.rb#189
752
- def eager_load_child_namespace(child, child_name, root_dir, root_namespace); end
753
- end
754
-
755
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#3
756
- module Zeitwerk::Loader::Helpers
757
- private
758
-
759
- # @return [Boolean]
760
- #
761
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#128
762
- def cdef?(parent, cname); end
763
-
764
- # @raise [NameError]
765
- #
766
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#134
767
- def cget(parent, cname); end
768
-
769
- # Symbol#name was introduced in Ruby 3.0. It returns always the same
770
- # frozen object, so we may save a few string allocations.
771
- #
772
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#118
773
- def cpath(parent, cname); end
774
-
775
- # @raise [NameError]
776
- #
777
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#140
778
- def crem(parent, cname); end
779
-
780
- # @return [Boolean]
781
- #
782
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#67
783
- def dir?(path); end
784
-
785
- # @return [Boolean]
786
- #
787
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#45
788
- def has_at_least_one_ruby_file?(dir); end
789
-
790
- # @return [Boolean]
791
- #
792
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#72
793
- def hidden?(basename); end
794
-
795
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#7
796
- def log(message); end
797
-
798
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#15
799
- def ls(dir); end
800
-
801
- # @return [Boolean]
802
- #
803
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#62
804
- def ruby?(path); end
805
-
806
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#109
807
- def strict_autoload_path(parent, cname); end
808
-
809
- # source://zeitwerk//lib/zeitwerk/loader/helpers.rb#77
810
- def walk_up(abspath); end
811
- end
812
-
813
- # source://zeitwerk//lib/zeitwerk/loader.rb#20
814
- Zeitwerk::Loader::MUTEX = T.let(T.unsafe(nil), Thread::Mutex)
815
-
816
- # source://zeitwerk//lib/zeitwerk/error.rb#13
817
- class Zeitwerk::NameError < ::NameError; end
818
-
819
- # source://zeitwerk//lib/zeitwerk/real_mod_name.rb#3
820
- module Zeitwerk::RealModName
821
- # source://zeitwerk//lib/zeitwerk/real_mod_name.rb#14
822
- def real_mod_name(mod); end
823
- end
824
-
825
- # source://zeitwerk//lib/zeitwerk/real_mod_name.rb#4
826
- Zeitwerk::RealModName::UNBOUND_METHOD_MODULE_NAME = T.let(T.unsafe(nil), UnboundMethod)
827
-
828
- # source://zeitwerk//lib/zeitwerk/registry.rb#4
829
- module Zeitwerk::Registry
830
- class << self
831
- # Maps absolute paths to the loaders responsible for them.
832
- #
833
- # This information is used by our decorated `Kernel#require` to be able to
834
- # invoke callbacks and autovivify modules.
835
- #
836
- # @private
837
- #
838
- # source://zeitwerk//lib/zeitwerk/registry.rb#26
839
- def autoloads; end
840
-
841
- # Registers gem loaders to let `for_gem` be idempotent in case of reload.
842
- #
843
- # @private
844
- #
845
- # source://zeitwerk//lib/zeitwerk/registry.rb#17
846
- def gem_loaders_by_root_file; end
847
-
848
- # @private
849
- # @return [Boolean]
850
- #
851
- # source://zeitwerk//lib/zeitwerk/registry.rb#113
852
- def inception?(cpath); end
853
-
854
- # This hash table addresses an edge case in which an autoload is ignored.
855
- #
856
- # For example, let's suppose we want to autoload in a gem like this:
857
- #
858
- # # lib/my_gem.rb
859
- # loader = Zeitwerk::Loader.new
860
- # loader.push_dir(__dir__)
861
- # loader.setup
862
- #
863
- # module MyGem
864
- # end
865
- #
866
- # if you require "my_gem", as Bundler would do, this happens while setting
867
- # up autoloads:
868
- #
869
- # 1. Object.autoload?(:MyGem) returns `nil` because the autoload for
870
- # the constant is issued by Zeitwerk while the same file is being
871
- # required.
872
- # 2. The constant `MyGem` is undefined while setup runs.
873
- #
874
- # Therefore, a directory `lib/my_gem` would autovivify a module according to
875
- # the existing information. But that would be wrong.
876
- #
877
- # To overcome this fundamental limitation, we keep track of the constant
878
- # paths that are in this situation ---in the example above, "MyGem"--- and
879
- # take this collection into account for the autovivification logic.
880
- #
881
- # Note that you cannot generally address this by moving the setup code
882
- # below the constant definition, because we want libraries to be able to
883
- # use managed constants in the module body:
884
- #
885
- # module MyGem
886
- # include MyConcern
887
- # end
888
- #
889
- # @private
890
- #
891
- # source://zeitwerk//lib/zeitwerk/registry.rb#65
892
- def inceptions; end
893
-
894
- # @private
895
- #
896
- # source://zeitwerk//lib/zeitwerk/registry.rb#121
897
- def loader_for(path); end
898
-
899
- # This method returns always a loader, the same instance for the same root
900
- # file. That is how Zeitwerk::Loader.for_gem is idempotent.
901
- #
902
- # @private
903
- #
904
- # source://zeitwerk//lib/zeitwerk/registry.rb#89
905
- def loader_for_gem(root_file, warn_on_extra_files:); end
906
-
907
- # Keeps track of all loaders. Useful to broadcast messages and to prevent
908
- # them from being garbage collected.
909
- #
910
- # @private
911
- #
912
- # source://zeitwerk//lib/zeitwerk/registry.rb#11
913
- def loaders; end
914
-
915
- # @private
916
- #
917
- # source://zeitwerk//lib/zeitwerk/registry.rb#127
918
- def on_unload(loader); end
919
-
920
- # @private
921
- #
922
- # source://zeitwerk//lib/zeitwerk/registry.rb#95
923
- def register_autoload(loader, abspath); end
924
-
925
- # @private
926
- #
927
- # source://zeitwerk//lib/zeitwerk/registry.rb#107
928
- def register_inception(cpath, abspath, loader); end
929
-
930
- # Registers a loader.
931
- #
932
- # @private
933
- #
934
- # source://zeitwerk//lib/zeitwerk/registry.rb#71
935
- def register_loader(loader); end
936
-
937
- # @private
938
- #
939
- # source://zeitwerk//lib/zeitwerk/registry.rb#101
940
- def unregister_autoload(abspath); end
941
-
942
- # @private
943
- #
944
- # source://zeitwerk//lib/zeitwerk/registry.rb#77
945
- def unregister_loader(loader); end
946
- end
947
- end
948
-
949
- # source://zeitwerk//lib/zeitwerk/error.rb#7
950
- class Zeitwerk::ReloadingDisabledError < ::Zeitwerk::Error
951
- # @return [ReloadingDisabledError] a new instance of ReloadingDisabledError
952
- #
953
- # source://zeitwerk//lib/zeitwerk/error.rb#8
954
- def initialize; end
955
- end
956
-
957
- # source://zeitwerk//lib/zeitwerk/error.rb#16
958
- class Zeitwerk::SetupRequired < ::Zeitwerk::Error
959
- # @return [SetupRequired] a new instance of SetupRequired
960
- #
961
- # source://zeitwerk//lib/zeitwerk/error.rb#17
962
- def initialize; end
963
- end
964
-
965
- # source://zeitwerk//lib/zeitwerk/version.rb#4
966
- Zeitwerk::VERSION = T.let(T.unsafe(nil), String)