class MinceMongoDb::Config
Config
¶ ↑
Config
specifies the configuration settings
@author Matt Simpson
The following fields can be changed:
-
database_name
- Defaults to 'mince' -
database_host
- Defaults to '127.0.0.1' -
username - Defaults to nil
-
password - Defaults to nil
The following fields cannot be changed:
You can change a field by passing a hash:
MinceMongoDb::Config.options = { username: 'my_db_user', password: 'my_db_passw0rd' }
Or you can change a field individually:
MinceMongoDb::Config.username = 'my_db_user'
If you are running tests in parallel, make sure that ENV is set for the instance number for each parallel test. This number is amended to the database name.
Constants
- OPTIONS
Attributes
database_host[RW]
database_name[RW]
password[RW]
primary_key[RW]
username[RW]
Public Class Methods
new()
click to toggle source
# File lib/mince_mongo_db/config.rb, line 83 def initialize self.primary_key = '_id' self.database_name = 'mince' self.database_host = '127.0.0.1' end
options()
click to toggle source
# File lib/mince_mongo_db/config.rb, line 56 def self.options { database_name: database_name, database_host: database_host, username: username, password: password } end
options=(new_options)
click to toggle source
# File lib/mince_mongo_db/config.rb, line 65 def self.options=(new_options) whitelist_keys(new_options).each do |key, value| send("#{key}=", value) end end
test_env_number()
click to toggle source
Returns the test environment number, useful for when testing with multiple processes in parallel
# File lib/mince_mongo_db/config.rb, line 77 def self.test_env_number ENV['TEST_ENV_NUMBER'] end
whitelist_keys(options)
click to toggle source
# File lib/mince_mongo_db/config.rb, line 71 def self.whitelist_keys(options) options.select{|key, value| OPTIONS.include?(key.to_s) } end
Public Instance Methods
database_name=(name)
click to toggle source
# File lib/mince_mongo_db/config.rb, line 89 def database_name=(name) @database_name = [name, self.class.test_env_number].compact.join("-") end