Skip to content

Commit

Permalink
Integrate zeitwerk autoload
Browse files Browse the repository at this point in the history
* According to https://community.theforeman.org/t/zeitwerk-merge-imminent/38429
* Requires Foreman 3.13
* Move Exception module for consistent autoloading

Co-authored-by: Nadja Heitmann <[email protected]>
  • Loading branch information
bastian-src and nadjaheitmann committed Oct 7, 2024
1 parent b30ad9e commit 54d829c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
File renamed without changes.
13 changes: 4 additions & 9 deletions lib/foreman_resource_quota/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ module ForemanResourceQuota
class Engine < ::Rails::Engine
engine_name 'foreman_resource_quota'

config.autoload_paths += Dir["#{config.root}/app/models/"]
config.autoload_paths += Dir["#{config.root}/app/controllers/"]
config.autoload_paths += Dir["#{config.root}/app/views/"]
config.autoload_paths += Dir["#{config.root}/app/services/foreman_resource_quota/"]
config.autoload_paths += Dir["#{config.root}/app/helpers/foreman_resource_quota/"]
config.autoload_paths += Dir["#{config.root}/lib/"]

# Add db migrations
initializer 'foreman_resource_quota.load_app_instance_data' do |app|
ForemanResourceQuota::Engine.paths['db/migrate'].existent.each do |path|
Expand All @@ -34,8 +27,10 @@ class Engine < ::Rails::Engine
end

# Plugin extensions
initializer 'foreman_resource_quota.register_plugin', before: :finisher_hook do |_app|
require 'foreman_resource_quota/register'
initializer 'foreman_resource_quota.register_plugin', before: :finisher_hook do |app|
app.reloader.to_prepare do
require 'foreman_resource_quota/register'
end
end

# Include concerns in this config.to_prepare block
Expand Down
2 changes: 1 addition & 1 deletion lib/foreman_resource_quota/register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# rubocop: disable Metrics/BlockLength
Foreman::Plugin.register :foreman_resource_quota do
requires_foreman '>= 3.5.0'
requires_foreman '>= 3.13'
# Apipie
apipie_documented_controllers ["#{ForemanResourceQuota::Engine.root}" \
'/app/controllers/foreman_resource_quot/api/v2/*.rb']
Expand Down

0 comments on commit 54d829c

Please sign in to comment.