Class: Chanko::Loader::ZeitwerkLoader
- Inherits:
-
Object
- Object
- Chanko::Loader::ZeitwerkLoader
- Defined in:
- lib/chanko/loader.rb
Class Method Summary collapse
- .add_unit_directory_to_eager_load_paths ⇒ Object
- .cache ⇒ Object
- .eager_load_units! ⇒ Object
- .load(name) ⇒ Object
- .prepare_eager_load ⇒ Object
Instance Method Summary collapse
- #constantize ⇒ Object
-
#initialize(name) ⇒ ZeitwerkLoader
constructor
A new instance of ZeitwerkLoader.
- #load ⇒ Object
Constructor Details
#initialize(name) ⇒ ZeitwerkLoader
Returns a new instance of ZeitwerkLoader.
58 59 60 |
# File 'lib/chanko/loader.rb', line 58 def initialize(name) @name = name end |
Class Method Details
.add_unit_directory_to_eager_load_paths ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/chanko/loader.rb', line 50 def self.add_unit_directory_to_eager_load_paths path = Chanko::Config.units_directory_path unless Rails.configuration.eager_load_paths.include?(path) Rails.configuration.eager_load_paths << path end end |
.cache ⇒ Object
35 36 37 38 |
# File 'lib/chanko/loader.rb', line 35 def self.cache # backward compatibility { } end |
.eager_load_units! ⇒ Object
40 41 42 |
# File 'lib/chanko/loader.rb', line 40 def self.eager_load_units! # Zeitwerk load chanko units as default end |
.load(name) ⇒ Object
31 32 33 |
# File 'lib/chanko/loader.rb', line 31 def self.load(name) self.new(name).load end |
.prepare_eager_load ⇒ Object
44 45 46 47 48 |
# File 'lib/chanko/loader.rb', line 44 def self.prepare_eager_load add_unit_directory_to_eager_load_paths Rails.autoloaders.main.collapse(Chanko::Config.units_directory_path + '/*') Rails.autoloaders.main.ignore(Chanko::Config.units_directory_path + '/*/spec*') end |
Instance Method Details
#constantize ⇒ Object
69 70 71 |
# File 'lib/chanko/loader.rb', line 69 def constantize @name.to_s.camelize.constantize end |
#load ⇒ Object
62 63 64 65 66 67 |
# File 'lib/chanko/loader.rb', line 62 def load constantize rescue NameError # Chanko never raise error even if the constant fails to reference false end |