Module: RailsSqlViews::Loader

Defined in:
lib/rails_sql_views/loader.rb

Constant Summary collapse

SUPPORTED_ADAPTERS =
%w( Mysql Mysql2 PostgreSQL SQLServer SQLite OracleEnhanced )

Class Method Summary collapse

Class Method Details

.load_extensionsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rails_sql_views/loader.rb', line 6

def self.load_extensions
  SUPPORTED_ADAPTERS.each do |db|
    if ActiveRecord::ConnectionAdapters.const_defined?("#{db}Adapter")
      require "rails_sql_views/connection_adapters/#{db.downcase}_adapter"
      ActiveRecord::ConnectionAdapters.const_get("#{db}Adapter").class_eval do
        include RailsSqlViews::ConnectionAdapters::AbstractAdapter
        include RailsSqlViews::ConnectionAdapters.const_get("#{db}Adapter")
        # prevent reloading extension when the environment is reloaded
        $rails_sql_views_included = true
      end
    end
  end
end