abstract_adapter.rb

Path: vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
Last Update: Thu Aug 04 22:20:26 UTC 2005

Required files

benchmark   date   rubygems  

Methods

Public Instance methods

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

[Source]

    # 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

[Validate]