Skip to content

Commit

Permalink
Load HykuKnapsack decorators
Browse files Browse the repository at this point in the history
This commit will allow the HykuKnapsack decorators to be loaded by the
application rb as well.
  • Loading branch information
kirkkwang committed Mar 15, 2024
1 parent d0e27dc commit 3fbf2f4
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,33 @@ def self.work_types
end

config.to_prepare do
# Load locales early so decorators can use them during initialization
I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.yml')]

# Allows us to use decorator files
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end

Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end

# OAI additions
Dir.glob(File.join(File.dirname(__FILE__), "../lib/oai/**/*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end

if defined?(HykuKnapsack)
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end

Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

if Hyku.bulkrax_enabled?
# set bulkrax default work type to first curation_concern if it isn't already set
Bulkrax.default_work_type = Hyku::Application.work_types.first.to_s if Bulkrax.default_work_type.blank?
Expand All @@ -234,23 +261,6 @@ def self.work_types
# Hyrax::FileSetDerivativesService]

DerivativeRodeo::Generators::HocrGenerator.additional_tessearct_options = nil

# Load locales early so decorators can use them during initialization
I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.yml')]

# Allows us to use decorator files
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end

Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end

# OAI additions
Dir.glob(File.join(File.dirname(__FILE__), "../lib/oai/**/*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

# When running tests we don't want to auto-specify factories
Expand Down

0 comments on commit 3fbf2f4

Please sign in to comment.