Class: CmisServer::ZeitwerkConfiguration
- Inherits:
-
Object
- Object
- CmisServer::ZeitwerkConfiguration
- Defined in:
- lib/cmis_server/zeitwerk_configuration.rb
Overview
Configuration for Zeitwerk autoloading This ensures proper class loading in Rails 7+
Class Method Summary collapse
Class Method Details
.setup ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cmis_server/zeitwerk_configuration.rb', line 5 def self.setup # Get main paths lib_path = File.('../../', __FILE__) app_path = File.('../../../app', __FILE__) # Setup for Rails 6+ with Zeitwerk if defined?(Rails) && Rails.respond_to?(:autoloaders) && Rails.autoloaders.respond_to?(:main) Rails.autoloaders.main.push_dir(lib_path, namespace: CmisServer) # Add controller directories with proper namespacing controllers_path = File.join(app_path, 'controllers', 'cmis_server') Rails.autoloaders.main.push_dir(controllers_path, namespace: CmisServer) if Dir.exist?(controllers_path) # Explicitly handle nested controllers atom_pub_path = File.join(controllers_path, 'atom_pub') if Dir.exist?(atom_pub_path) Rails.autoloaders.main.push_dir(atom_pub_path, namespace: CmisServer::AtomPub) end # Add models, views and services %w[models views services].each do |dir| path = File.join(app_path, dir, 'cmis_server') Rails.autoloaders.main.push_dir(path, namespace: CmisServer) if Dir.exist?(path) end Rails.logger&.info "CMIS: Zeitwerk autoloading configured" end end |