Class: PseudoCleaner::Configuration
- Inherits:
-
Object
- Object
- PseudoCleaner::Configuration
- Includes:
- Singleton
- Defined in:
- lib/pseudo_cleaner/configuration.rb
Instance Attribute Summary collapse
-
#benchmark ⇒ Object
Returns the value of attribute benchmark.
-
#clean_database_before_tests ⇒ Object
Returns the value of attribute clean_database_before_tests.
-
#db_connections ⇒ Object
Returns the value of attribute db_connections.
-
#disable_cornucopia_output ⇒ Object
Returns the value of attribute disable_cornucopia_output.
-
#enable_full_data_dump_tag ⇒ Object
Returns the value of attribute enable_full_data_dump_tag.
-
#output_diagnostics ⇒ Object
A simple configuration class for the PseudoCleaner.
-
#peek_data_not_on_error ⇒ Object
Returns the value of attribute peek_data_not_on_error.
-
#peek_data_on_error ⇒ Object
Returns the value of attribute peek_data_on_error.
-
#post_transaction_analysis ⇒ Object
Returns the value of attribute post_transaction_analysis.
-
#redis_track_reads ⇒ Object
Returns the value of attribute redis_track_reads.
-
#reset_auto_increment ⇒ Object
Returns the value of attribute reset_auto_increment.
-
#single_cleaner_set ⇒ Object
Returns the value of attribute single_cleaner_set.
Class Method Summary collapse
- .current_instance ⇒ Object
- .db_connection(type) ⇒ Object
-
.db_connection=(connection) ⇒ Object
Backwards comaptibility…
Instance Method Summary collapse
- #db_connection(type) ⇒ Object
- #db_connection=(connection) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |
Instance Attribute Details
#benchmark ⇒ Object
Returns the value of attribute benchmark.
22 23 24 |
# File 'lib/pseudo_cleaner/configuration.rb', line 22 def benchmark @benchmark end |
#clean_database_before_tests ⇒ Object
Returns the value of attribute clean_database_before_tests.
13 14 15 |
# File 'lib/pseudo_cleaner/configuration.rb', line 13 def clean_database_before_tests @clean_database_before_tests end |
#db_connections ⇒ Object
Returns the value of attribute db_connections.
17 18 19 |
# File 'lib/pseudo_cleaner/configuration.rb', line 17 def db_connections @db_connections end |
#disable_cornucopia_output ⇒ Object
Returns the value of attribute disable_cornucopia_output.
21 22 23 |
# File 'lib/pseudo_cleaner/configuration.rb', line 21 def disable_cornucopia_output @disable_cornucopia_output end |
#enable_full_data_dump_tag ⇒ Object
Returns the value of attribute enable_full_data_dump_tag.
20 21 22 |
# File 'lib/pseudo_cleaner/configuration.rb', line 20 def enable_full_data_dump_tag @enable_full_data_dump_tag end |
#output_diagnostics ⇒ Object
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...
12 13 14 |
# File 'lib/pseudo_cleaner/configuration.rb', line 12 def output_diagnostics @output_diagnostics end |
#peek_data_not_on_error ⇒ Object
Returns the value of attribute peek_data_not_on_error.
19 20 21 |
# File 'lib/pseudo_cleaner/configuration.rb', line 19 def peek_data_not_on_error @peek_data_not_on_error end |
#peek_data_on_error ⇒ Object
Returns the value of attribute peek_data_on_error.
18 19 20 |
# File 'lib/pseudo_cleaner/configuration.rb', line 18 def peek_data_on_error @peek_data_on_error end |
#post_transaction_analysis ⇒ Object
Returns the value of attribute post_transaction_analysis.
16 17 18 |
# File 'lib/pseudo_cleaner/configuration.rb', line 16 def post_transaction_analysis @post_transaction_analysis end |
#redis_track_reads ⇒ Object
Returns the value of attribute redis_track_reads.
23 24 25 |
# File 'lib/pseudo_cleaner/configuration.rb', line 23 def redis_track_reads @redis_track_reads end |
#reset_auto_increment ⇒ Object
Returns the value of attribute reset_auto_increment.
14 15 16 |
# File 'lib/pseudo_cleaner/configuration.rb', line 14 def reset_auto_increment @reset_auto_increment end |
#single_cleaner_set ⇒ Object
Returns the value of attribute single_cleaner_set.
15 16 17 |
# File 'lib/pseudo_cleaner/configuration.rb', line 15 def single_cleaner_set @single_cleaner_set end |
Class Method Details
.current_instance ⇒ Object
25 26 27 |
# File 'lib/pseudo_cleaner/configuration.rb', line 25 def self.current_instance self.instance end |
.db_connection(type) ⇒ Object
49 50 51 |
# File 'lib/pseudo_cleaner/configuration.rb', line 49 def self.db_connection(type) self.instance.db_connection(type) end |
.db_connection=(connection) ⇒ Object
Backwards comaptibility…
45 46 47 |
# File 'lib/pseudo_cleaner/configuration.rb', line 45 def self.db_connection=(connection) self.instance.db_connection = connection end |
Instance Method Details
#db_connection(type) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# 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) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# 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 |