Module: Kernel
- Extended by:
- RuxRails::LoadPatch
- Defined in:
- lib/rux-rails/core_ext/kernel.rb,
lib/rux-rails/core_ext/kernel_zeitwerk.rb
Instance Method Summary collapse
- #load(file, *args) ⇒ Object
- #require(file) ⇒ Object
- #rux_orig_load ⇒ Object
- #rux_orig_require ⇒ Object
Instance Method Details
#load(file, *args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rux-rails/core_ext/kernel_zeitwerk.rb', line 7 def load(file, *args) if File.extname(file) == '.rux' tmpl = Rux::File.new(file) tmpl.write if RuxRails.transpile_on_load? # I don't understand why, but it's necessary to delete the constant # in order to load the .ruxc file. Otherwise you get an error about # an uninitialized constant, and it's like... yeah, I _know_ it's # uninitialized, that's why I'm loading this file. Whatevs. loader = Zeitwerk::Registry.loader_for(file) parent, cname = loader.autoloads[file] parent.send(:remove_const, cname) return rux_orig_load(tmpl.default_outfile, *args) end rux_orig_load(file, *args) end |
#require(file) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rux-rails/core_ext/kernel_zeitwerk.rb', line 26 def require(file) path = nil loader = Zeitwerk::Registry.loader_for(file) rux_file = file.end_with?('.rux') ? file : "#{file}.rux" if File.absolute_path(rux_file) == rux_file && File.exist?(rux_file) path = rux_file elsif rux_file.start_with?(".#{File::SEPARATOR}") abs_path = File.(rux_file) path = abs_path if File.exist?(abs_path) else $LOAD_PATH.each do |lp| check_path = File.(File.join(lp, rux_file)) if File.exist?(check_path) path = check_path break end end end unless path # This will be either Ruby's original require or bootsnap's monkeypatched # require in setups that use bootsnap. Lord help us with all these layers # of patches. return zeitwerk_original_require(file) end return false if $LOADED_FEATURES.include?(path) load path $LOADED_FEATURES << path loader.on_file_autoloaded(path) if loader return true end |
#rux_orig_load ⇒ Object
5 |
# File 'lib/rux-rails/core_ext/kernel_zeitwerk.rb', line 5 alias_method :rux_orig_load, :load |
#rux_orig_require ⇒ Object
4 |
# File 'lib/rux-rails/core_ext/kernel_zeitwerk.rb', line 4 alias_method :rux_orig_require, :require |