class PseudoCleaner::Configuration

Attributes

benchmark[RW]
clean_database_before_tests[RW]
db_connections[RW]
disable_cornucopia_output[RW]
enable_full_data_dump_tag[RW]
output_diagnostics[RW]

A simple configuration class for the PseudoCleaner

Configurations:

output_diagnostics  - true/false
                      if true, the system will use puts to output information about what it is doing...
peek_data_not_on_error[RW]
peek_data_on_error[RW]
post_transaction_analysis[RW]
redis_track_reads[RW]
reset_auto_increment[RW]
single_cleaner_set[RW]

Public Class Methods

current_instance() click to toggle source
# File lib/pseudo_cleaner/configuration.rb, line 25
def self.current_instance
  self.instance
end
db_connection(type) click to toggle source
# File lib/pseudo_cleaner/configuration.rb, line 49
def self.db_connection(type)
  self.instance.db_connection(type)
end
db_connection=(connection) click to toggle source

Backwards comaptibility…

# File lib/pseudo_cleaner/configuration.rb, line 45
def self.db_connection=(connection)
  self.instance.db_connection = connection
end
new() click to toggle source
# File lib/pseudo_cleaner/configuration.rb, line 29
def initialize
  @output_diagnostics          = false # false to keep the noise level down...
  @clean_database_before_tests = false # false because I think it will annoy developers...
  @reset_auto_increment        = true # true because I think it should be done
  @single_cleaner_set          = true # true because I hope it will improve performance
  @post_transaction_analysis   = false # should only be set true if you are searching for a problem
  @db_connections              = {}
  @peek_data_on_error          = true
  @peek_data_not_on_error      = false
  @enable_full_data_dump_tag   = true
  @disable_cornucopia_output   = false
  @benchmark                   = false
  @redis_track_reads           = false
end

Public Instance Methods

db_connection(type) click to toggle source
# File lib/pseudo_cleaner/configuration.rb, line 70
def db_connection(type)
  if (!type)
    if Object.const_defined?("Sequel", false) && Sequel.const_defined?("Model", false)
      type = :sequel
    else
      type = :active_record
    end
  end

  if type == :sequel
    @db_connections[type] ||= Sequel::DATABASES[0]
  else
    @db_connections[type] ||= ActiveRecord::Base
  end

  @db_connections[type]
end
db_connection=(connection) click to toggle source
# File lib/pseudo_cleaner/configuration.rb, line 53
def db_connection=(connection)
  if Object.const_defined?("ActiveRecord", false) && ActiveRecord.const_defined?("Base", false)
    table_is_active_record = connection == ActiveRecord::Base
    table_super_class      = connection.superclass if connection
    while !table_is_active_record && table_super_class
      table_is_active_record = (table_super_class == ActiveRecord::Base)
      table_super_class      = table_super_class.superclass
    end

    @db_connections[:active_record] = connection if table_is_active_record
  end

  if Object.const_defined?("Sequel", false) && Sequel.const_defined?("Model", false)
    @db_connections[:sequel] = connection
  end
end