Permalink
Browse files

Fix plugin loading when plugin module name is the same as an already …

…defined top level constant

This happened with the active_model plugin, which caused errors if
::ActiveModel was already defined, a common situation when using
the Rails3 beta.
  • Loading branch information...
1 parent 34c8d2a commit 977dd3fb7b4143fb4b517203fdf5adc89f073f4e @jeremyevans committed Mar 25, 2010
Showing with 5 additions and 1 deletion.
  1. +2 −0 CHANGELOG
  2. +3 −1 lib/sequel/model/plugins.rb
View
@@ -1,5 +1,7 @@
=== HEAD
+* Fix plugin loading when plugin module name is the same as an already defined top level constant (jeremyevans)
+
* Add an AS400 JDBC subadapter (need jt400.jar in classpath) (jeremyevans, bhauff)
* Fix the emulated MSSQL offset support when core extensions are not used (jeremyevans)
@@ -64,7 +64,9 @@ module ClassMethods
# defined, the corresponding plugin gem is automatically loaded.
def plugin_module(plugin)
module_name = plugin.to_s.gsub(/(^|_)(.)/){|x| x[-1..-1].upcase}
- if not Sequel::Plugins.const_defined?(module_name)
+ if !Sequel::Plugins.const_defined?(module_name) ||
+ (Sequel.const_defined?(module_name) &&
+ Sequel::Plugins.const_get(module_name) == Sequel.const_get(module_name))
begin
Sequel.tsk_require "sequel/plugins/#{plugin}"
rescue LoadError

0 comments on commit 977dd3f

Please sign in to comment.