Method: DataObjects::Connection.inherited
- Defined in:
- lib/data_objects/connection.rb
.inherited(target) ⇒ Object
Ensure that all Connection subclasses handle pooling and logging uniformly. See also DataObjects::Pooling and DataObjects::Logger
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/data_objects/connection.rb', line 73 def self.inherited(target) target.class_eval do # Allocate a Connection object from the pool, creating one if necessary. This method is active in Connection subclasses only. def self.new(*args) instance = allocate instance.send(:initialize, *args) instance end include Quoting end if driver_module_name = target.name.split('::')[-2] driver_module = DataObjects::const_get(driver_module_name) driver_module.class_eval <<-EOS, __FILE__, __LINE__ def self.logger @logger end def self.logger=(logger) @logger = logger end EOS driver_module.logger = DataObjects::Logger.new(nil, :off) end end |