Method: Jets::Booter.load_shared_extensions

Defined in:
lib/jets/booter.rb

.load_shared_extensionsObject

Shared extensions are added near the end because they require the Jets app load paths to first. We eager load the extensions and then use the loaded modules to extend Jets::Stack directly. Originally used an included hook but thats too early before app/shared/extensions is in the load_path.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/jets/booter.rb', line 45

def load_shared_extensions
  Jets::Autoloaders.once.preload("#{Jets.root}/app/shared/extensions")
  base_path = "#{Jets.root}/app/shared/extensions"
  Dir.glob("#{base_path}/**/*.rb").each do |path|
    next unless File.file?(path)

    class_name = path.sub("#{base_path}/", '').sub(/\.rb/,'').camelize
    mod = class_name.constantize # autoload
    Jets::Stack.extend(mod)
  end
end