Module: ActiveRecord::DynamicTimeout::Initializer
- Defined in:
- lib/active_record/dynamic_timeout/initializer.rb
Class Method Summary collapse
Class Method Details
.initialize! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_record/dynamic_timeout/initializer.rb', line 15 def initialize! ActiveRecord::Base.include(ActiveRecord::DynamicTimeout::BaseExtension) ActiveRecord::Base.connection.class.include(ActiveRecord::DynamicTimeout::AbstractAdapterExtension) if ActiveRecord.gem_version < "7.1" ActiveRecord::Base.connection.class.prepend(ActiveRecord::DynamicTimeout::TimeoutAdapterExtension_Rails_7_0) else ActiveRecord::Base.connection.class.prepend(ActiveRecord::DynamicTimeout::TimeoutAdapterExtension) end register_adapter_extension(ActiveRecord::Base.connection.class) end |
.register_adapter_extension(adapter_class) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/active_record/dynamic_timeout/initializer.rb', line 27 def register_adapter_extension(adapter_class) extension = case adapter_class.name when "ActiveRecord::ConnectionAdapters::Mysql2Adapter" ActiveRecord::DynamicTimeout::Mysql2AdapterExtension when "ActiveRecord::ConnectionAdapters::TrilogyAdapter" ActiveRecord::DynamicTimeout::TrilogyAdapterExtension when "ActiveRecord::ConnectionAdapters::SQLite3Adapter" ActiveRecord::DynamicTimeout::SqliteAdapterExtension when "ActiveRecord::ConnectionAdapters::PostgreSQLAdapter" ActiveRecord::DynamicTimeout::PostgresAdapterExtension end adapter_class.include(extension) if extension end |