提交 fe41c703 编写于 作者: C Carlhuda

Stop evalling the environment file in favor of require + setting a...

Stop evalling the environment file in favor of require + setting a Kernel#config. This will fix the bug where reopening classes caused them to be overwritten.
上级 39034997
......@@ -82,6 +82,23 @@ def call(env)
@app.call(env)
end
# Loads the environment specified by Configuration#environment_path, which
# is typically one of development, test, or production.
initializer :load_environment do
next unless File.file?(config.environment_path)
config = self.config
Kernel.class_eval do
meth = instance_method(:config) if Object.respond_to?(:config)
define_method(:config) { config }
require config.environment_path
remove_method :config
define_method(:config, &meth) if meth
end
end
# Set the <tt>$LOAD_PATH</tt> based on the value of
# Configuration#load_paths. Duplicates are removed.
initializer :set_load_path do
......@@ -123,24 +140,6 @@ def call(env)
end
end
# Loads the environment specified by Configuration#environment_path, which
# is typically one of development, test, or production.
initializer :load_environment do
silence_warnings do
next if @environment_loaded
next unless File.file?(config.environment_path)
@environment_loaded = true
constants = self.class.constants
eval(IO.read(config.environment_path), binding, config.environment_path)
(self.class.constants - constants).each do |const|
Object.const_set(const, self.class.const_get(const))
end
end
end
# Preload all frameworks specified by the Configuration#frameworks.
# Used by Passenger to ensure everything's loaded before forking and
# to avoid autoload race conditions in JRuby.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册