Class: DbEntropy::Mongoid

Inherits:
Base
  • Object
show all
Defined in:
lib/db-entropy/mongoid.rb

Instance Attribute Summary

Attributes inherited from Base

#extra_environments

Instance Method Summary collapse

Methods inherited from Base

#generate_random_name, #generate_yaml, #initialize, #write_to_yaml

Constructor Details

This class inherits a constructor from DbEntropy::Base

Instance Method Details

#generate_database_configObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/db-entropy/mongoid.rb', line 2

def generate_database_config
  db_config = %w(development test).inject({}) do |conf, env|
    conf[env] = {'host'                   => 'localhost',
                 'allow_dynamic_fields'   => true,
                 'parameterize_keys'      => true,
                 'persist_in_safe_mode'   => true,
                 'raise_not_found_error'  => true,
                 'reconnect_time'         => 3,
                 'use_object_ids'         => false,
                 'database'               => "entropy_#{generate_random_name}"}
    conf
  end
  extra_environments.each do |env|
    db_config[env] = db_config['test']
  end
  db_config
end