Class: DatabaseRecorder::Config
- Inherits:
-
Object
- Object
- DatabaseRecorder::Config
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/database_recorder/config.rb
Constant Summary collapse
- DEFAULT_DB_DRIVER =
:active_record
- DEFAULT_LOG_FORMAT =
'[DB] %sql [%name]'
- DEFAULT_STORAGE =
DatabaseRecorder::Storage::File
- DB_DRIVER_VALUES =
%i[active_record mysql2 pg].freeze
- PRINT_QUERIES_VALUES =
[false, true, :color].freeze
- STORAGE_VALUES =
{ file: DatabaseRecorder::Storage::File, redis: DatabaseRecorder::Storage::Redis }.freeze
Instance Attribute Summary collapse
-
#db_driver ⇒ Object
Returns the value of attribute db_driver.
-
#log_format ⇒ Object
Returns the value of attribute log_format.
-
#print_queries ⇒ Object
Returns the value of attribute print_queries.
-
#replay_recordings ⇒ Object
Returns the value of attribute replay_recordings.
-
#storage ⇒ Object
Returns the value of attribute storage.
-
#storage_options ⇒ Object
Returns the value of attribute storage_options.
Class Method Summary collapse
- .db_driver=(value) ⇒ Object
- .load_defaults ⇒ Object
- .print_queries=(value) ⇒ Object
- .storage=(value) ⇒ Object
Instance Attribute Details
#db_driver ⇒ Object
Returns the value of attribute db_driver.
21 22 23 |
# File 'lib/database_recorder/config.rb', line 21 def db_driver @db_driver end |
#log_format ⇒ Object
Returns the value of attribute log_format.
21 22 23 |
# File 'lib/database_recorder/config.rb', line 21 def log_format @log_format end |
#print_queries ⇒ Object
Returns the value of attribute print_queries.
21 22 23 |
# File 'lib/database_recorder/config.rb', line 21 def print_queries @print_queries end |
#replay_recordings ⇒ Object
Returns the value of attribute replay_recordings.
21 22 23 |
# File 'lib/database_recorder/config.rb', line 21 def replay_recordings @replay_recordings end |
#storage ⇒ Object
Returns the value of attribute storage.
21 22 23 |
# File 'lib/database_recorder/config.rb', line 21 def storage @storage end |
#storage_options ⇒ Object
Returns the value of attribute storage_options.
21 22 23 |
# File 'lib/database_recorder/config.rb', line 21 def @storage_options end |
Class Method Details
.db_driver=(value) ⇒ Object
38 39 40 |
# File 'lib/database_recorder/config.rb', line 38 def db_driver=(value) instance.db_driver = DB_DRIVER_VALUES.include?(value) ? value : DEFAULT_DB_DRIVER end |
.load_defaults ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/database_recorder/config.rb', line 29 def load_defaults instance.db_driver = DEFAULT_DB_DRIVER instance.log_format = DEFAULT_LOG_FORMAT instance.print_queries = false instance.replay_recordings = false instance.storage = DEFAULT_STORAGE instance. = {} end |
.print_queries=(value) ⇒ Object
42 43 44 |
# File 'lib/database_recorder/config.rb', line 42 def print_queries=(value) instance.print_queries = PRINT_QUERIES_VALUES.include?(value) ? value : false end |
.storage=(value) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/database_recorder/config.rb', line 46 def storage=(value) instance.storage = if value.is_a?(Class) && value < Storage::Base value else STORAGE_VALUES[value] end end |