| Path: | vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb |
| Last Update: | Mon Jul 25 13:23:36 UTC 2005 |
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
# File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, line 8
8: def require_library_or_gem(library_name)
9: begin
10: require library_name
11: rescue LoadError => cannot_require
12: # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
13: begin
14: require 'rubygems'
15: rescue LoadError => rubygems_not_installed
16: raise cannot_require
17: end
18: # 2. Rubygems is installed and loaded. Try to load the library again
19: begin
20: require library_name
21: rescue LoadError => gem_not_installed
22: raise cannot_require
23: end
24: end
25: end