Module: Appfuel::Config
- Defined in:
- lib/appfuel/config.rb,
lib/appfuel/config/db.rb,
lib/appfuel/config/search.rb,
lib/appfuel/config/populate.rb,
lib/appfuel/config/file_loader.rb,
lib/appfuel/config/definition_dsl.rb
Defined Under Namespace
Modules: FileLoader, Populate, Search Classes: DefinitionDsl
Class Method Summary collapse
-
.db_definition ⇒ Object
Defines database configuration.
- .define(key, &block) ⇒ Object
Class Method Details
.db_definition ⇒ Object
Defines database configuration. This is designed to hold more than one database connection which is why they are named invidually. We are using active record so the config is taylored to that style connection.
Configuration Overview
pool: Managed connection which controls the amount of thread access to
a limited number of database connections
adapter: We always use postgres, rarely changes encoding: We always use unicode, rarely changes database Name of the database username Name of the database user password Database password host Location of the database server
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/appfuel/config/db.rb', line 19 def self.db_definition define :db do validator { required(:main).filled(:hash?) required(:path).filled(:str?) required(:seed_path).filled(:str?) required(:migrations_path).filled(:str?) } db_path = 'db' defaults path: db_path, migrations_path: "#{db_path}/migrations", seed_path: 'db/seed' define :main do defaults pool: 5, adapter: 'postgresql', encoding: 'unicode', schema_format: 'sql' validator do required(:schema_search_path).filled(:str?) required(:schema_format).filled(:str?) required(:database).filled(:str?) required(:username).filled(:str?) required(:password).filled(:str?) required(:host).filled(:str?) required(:adapter).filled(:str?) optional(:pool).filled(:int?) optional(:encoding).filled(:str?) optional(:port).filled(:int?) end end end end |
.define(key, &block) ⇒ Object
9 10 11 12 13 |
# File 'lib/appfuel/config.rb', line 9 def self.define(key, &block) definition = DefinitionDsl.new(key) definition.instance_eval(&block) definition end |