[Config-loader] [Config Loader] Controlling which files / dirs are
merged was updated
Config Loader
noreply at google.com
Sat Aug 30 16:26:11 BST 2008
Clinton Gormley updated the page Controlling which files / dirs are merged.=
=
View the changes below.
Color key: Insertion | Deletion
What is merging?
Merging differs from loading in that particular keys can be overriden. For =
instance, if the current config hash looks like:
$config =3D {
db =3D> {
main =3D> {
username =3D> 'dbuser',
password =3D> 'mypass',
host =3D> 'db1.domain.com'
}
}
}
We could merge in:
$merge =3D {
db =3D> {
main =3D> {
host =3D> 'devdb.domain.com'
}
}
}
To result in:
$config =3D {
db =3D> {
main =3D> {
username =3D> 'dbuser',
password =3D> 'mypass',
host =3D> 'devdb.domain.com'
}
}
}
Before a file is considered for merging, it first has to pass the load_if /=
=
load_unless checks. (see Controlling which files / dirs are loaded for =
details)
merge_if / merge_unless / merge_path_if / merge_path_unless are direct =
counterparts of load_if / load_unless / load_path_if / load_path_unless
merge _if rules will be run before merge _unless . So if merge _if returns =
true, and merge _unless ALSO returns true, the end result will be DO NOT =
MERGE ie load/replace instead.
Possible values
The values passed to merge_if* and merge_ unless* can be:
a string -> eq
a regex -> m//
a sub ref -> $_->($name)
a hash ref -> exists $_->{$name}
an array ref, which can contain any of the above
$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
merge_if =3D> qr/_local/,
merge_unless =3D> qr/_local_test/,
});
$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
merge_if_path =3D> qr/_local/,
merge_unless_path =3D> qr/_local_test/,
});
$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
merge_if =3D> sub {...},
merge_unless =3D> sub {...},
});
$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
merge_if =3D> [ qr/_local/, sub {...}],
merge_unless =3D> [ qr/_local_test/, sub {...}],
});
$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
merge_if =3D> [ qr/_local/, sub {...}],
merge_unless =3D> [ qr/_local_test/, sub {...}],
});
Go to page: Controlling which files / dirs are merged
-------------
You requested this notification from Google Sites. You can unsubscribe at =
any time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/config-loader/attachments/20080830/=
22911b0b/attachment.htm
More information about the Config-loader
mailing list