diff options
author | Jamis Buck <jamis@37signals.com> | 2005-11-07 14:01:56 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-11-07 14:01:56 +0000 |
commit | fa0a5973dbc306651c4d7bb90020b9a92506a8bf (patch) | |
tree | 68e21fabc06bea85d62911e9d2cd8f157a8942b9 /railties/lib | |
parent | 3c31062c3d5f7092a13029d90c861396b91a1a22 (diff) | |
download | rails-fa0a5973dbc306651c4d7bb90020b9a92506a8bf.tar.gz rails-fa0a5973dbc306651c4d7bb90020b9a92506a8bf.tar.bz2 rails-fa0a5973dbc306651c4d7bb90020b9a92506a8bf.zip |
Restore access to 'directory' and 'config' inside the plugin eval environment
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2919 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/initializer.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index f0eceb0a4e..e412091d18 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -284,20 +284,23 @@ module Rails # Returns <tt>true</tt> if the plugin is successfully loaded or # <tt>false</tt> if it is already loaded (similar to Kernel#require). # Raises <tt>LoadError</tt> if the plugin is not found. - def load_plugin(path) - name = File.basename(path) - return false if loaded_plugins.include?(name) + def load_plugin(directory) + name = File.basename(directory) + return false if loaded_plugins.include?(directory) # Catch nonexistent and empty plugins. - raise LoadError, "No such plugin: #{path}" unless plugin_path?(path) + raise LoadError, "No such plugin: #{directory}" unless plugin_path?(directory) - lib_path = File.join(path, 'lib') - init_path = File.join(path, 'init.rb') + lib_path = File.join(directory, 'lib') + init_path = File.join(directory, 'init.rb') has_lib = File.directory?(lib_path) has_init = File.file?(init_path) # Add lib to load path. $LOAD_PATH.unshift(lib_path) if has_lib + + # Allow plugins to reference the current configuration object + config = configuration # Evaluate init.rb. silence_warnings { eval(IO.read(init_path), binding) } if has_init |