Browse files

Move require_library_or_gem out of AR's abstract_adapter and into Act…

…iveSupport. closes #1992

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2490 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 60a60f9 commit 80cd2f664527607e901a4e114098c5dc63587e3b Marcel Molina committed Oct 8, 2005
View
23 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -7,29 +7,6 @@
require 'active_record/connection_adapters/abstract/quoting'
require 'active_record/connection_adapters/abstract/connection_specification'
-# Method that requires a library, ensuring that rubygems is loaded
-# This is used in the database adaptors to require DB drivers. Reasons:
-# (1) database drivers are the only third-party library that Rails depend upon
-# (2) they are often installed as gems
-def require_library_or_gem(library_name)
- begin
- require library_name
- rescue LoadError => cannot_require
- # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
- begin
- require 'rubygems'
- rescue LoadError => rubygems_not_installed
- raise cannot_require
- end
- # 2. Rubygems is installed and loaded. Try to load the library again
- begin
- require library_name
- rescue LoadError => gem_not_installed
- raise cannot_require
- end
- end
-end
-
module ActiveRecord
module ConnectionAdapters # :nodoc:
# All the concrete database adapters follow the interface laid down in this class.
View
2 activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Moved require_library_or_gem into Kernel. #1992 [Michael Schuerig <michael@schuerig.de>]
+
* Add :rfc822 as an option for Time#to_s (to get rfc822-formatted times)
* Chain the const_missing hook to any previously existing hook so rails can play nicely with rake
View
22 activesupport/lib/active_support/core_ext/kernel.rb
@@ -28,4 +28,26 @@ def silence_warnings
ensure
$VERBOSE = old_verbose
end
+
+ # Method that requires a library, ensuring that rubygems is loaded
+ def require_library_or_gem(library_name)
+ begin
+ require library_name
+ rescue LoadError => cannot_require
+ # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
+ begin
+ require 'rubygems'
+ rescue LoadError => rubygems_not_installed
+ raise cannot_require
+ end
+ # 2. Rubygems is installed and loaded. Try to load the library again
+ begin
+ require library_name
+ rescue LoadError => gem_not_installed
+ raise cannot_require
+ end
+ end
+ end
+
+
end

0 comments on commit 80cd2f6

Please sign in to comment.