Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 9a3eb2a

Browse files
committed
Move initialization of the Config instance into the "config.before_initialize" block
1 parent e093212 commit 9a3eb2a

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

lib/requirejs/rails/engine.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,21 @@
55
module Requirejs
66
module Rails
77
class Engine < ::Rails::Engine
8-
98
### Configuration setup
10-
config.before_configuration do
11-
config.requirejs = Requirejs::Rails::Config.new
12-
config.requirejs.precompile = [/require\.js$/]
13-
end
14-
159
config.before_initialize do |app|
1610
config = app.config
1711

12+
config.requirejs = Requirejs::Rails::Config.new
13+
config.requirejs.precompile = [/require\.js$/]
14+
1815
# Process the user config file in #before_initalization (instead of #before_configuration) so that
1916
# environment-specific configuration can be injected into the user configuration file
20-
process_user_config_file(app, config)
17+
Engine.process_user_config_file(app, config)
2118

2219
config.assets.precompile += config.requirejs.precompile
2320

2421
manifest_directory = config.assets.manifest || File.join(::Rails.public_path, config.assets.prefix)
25-
manifest_path = File.join(manifest_directory, "rjs_manifest.yml")
22+
manifest_path = File.join(manifest_directory, "rjs_manifest.yml")
2623
config.requirejs.manifest_path = Pathname.new(manifest_path)
2724
end
2825

@@ -58,13 +55,11 @@ class Engine < ::Rails::Engine
5855
end
5956
end
6057

61-
private
62-
6358
# Process the user-supplied config parameters, which will be
6459
# merged with the default params. It should be a YAML file with
6560
# a single top-level hash, keys/values corresponding to require.js
6661
# config parameters.
67-
def process_user_config_file(app, config)
62+
def self.process_user_config_file(app, config)
6863
config_path = Pathname.new(app.paths["config"].first)
6964
config.requirejs.user_config_file = config_path+'requirejs.yml'
7065

0 commit comments

Comments
 (0)