The module Config::Loader Config::Merge has the ability to override the default config with local values. For instance, on your development machine, you may want to use a different database host. So you can override just that value:
app: servers: db: host: db.domain.com username: username password: password email: host: mail.domain.com etc
Then override/merge with:
app: servers: db: host: dev.domain.com email: host: dev.domain.com
A deep merge of hashes is done, so that the other config data is preserved.
I would like to provide a mechanism for altering arrays, rather than just having to copy and paste the entire array. So what I have thought of is the following:
main: cronjobs: - job1 - job2 - job3 - job4 - job5
Then override/merge with:
main: cronjobs: '!' : # key '!' must exist to signal m +erge '-' : # delete elements 3 and 5 - 3 - 5 '+' : # append jobs 6 and 7 - job6 - job7 OR '+' : # insert job8 at index 2, job9 a +t index 5 2: job8 5: job9 1: job10 # change index1 from job2 to job +10
thanks
Clint
UPDATE - corrected hostname to host (thanks fenLisesi)
UPDATE - change the module name to Config::Merge
In reply to RFC: An "API" for overriding array values in config data by clinton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |