-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
56 lines (32 loc) · 1.35 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
54
55
56
ApplicationConfig
=================
Basically there are 2 levels of configuration:
1) application wide which is configured in config/application.yml
2) environment specific which is configured in config/environments/application-#{RAILS_ENV}.yml
The environment specific configs override the applicaiton wide config
Example
=======
script/install plugin git://github.com/asynchrony/application_config.git
Then if for example in your config/application.yml you had:
mail_host: example.com
And in your config/environments/application-production.yml you had:
mail_host: production.server.com
you could in your code do:
ApplicationConfig::Base['mail_host'].to_s or
ApplicationConfig::Base.mail_host.to_s
At the moment you really need the to_s on the end.
Also, if you want to do a nil check you need to put the applicaiton config on the LHS:
if ApplicationConfig::Base.mail_host == nil
Because of the way it's working.
For testing, first:
require 'application_config_test_ext'
in your test_helper
And then before any test you want to alter the config for:
ApplicationConfig::Base.add(
<<EOF
mail_host: test_mail_host
EOF
)
Which will change the config for that test and then rollback to what it was before the test.
This allows you to test behavior off of the singleton config object.
Copyright (c) 2009 [name of plugin creator], released under the MIT license