Sha256: e3f9124904949d088a38648cb4aa2e57048fddf20280ee22723640bbeedfac15
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
require 'database_cleaner/generic/base' require 'active_record' module DatabaseCleaner module ActiveRecord def self.available_strategies %w[truncation transaction] end def self.config_file_location "#{DatabaseCleaner.app_root}/config/database.yml" end module Base include ::DatabaseCleaner::Generic::Base attr_accessor :connection_hash def db=(desired_db) @db = desired_db load_config end def db @db || super end def load_config connection_details = YAML::load(ERB.new(IO.read(ActiveRecord.config_file_location)).result) self.connection_hash = connection_details[self.db.to_s] end def create_connection_klass Class.new(::ActiveRecord::Base) end def connection_klass return ::ActiveRecord::Base if connection_hash.nil? klass = create_connection_klass klass.send :establish_connection, connection_hash klass end end end end
Version data entries
3 entries across 3 versions & 1 rubygems