[Catalyst] Merging configs
Bill Moseley
moseley at hank.org
Fri Mar 9 15:03:43 GMT 2007
On Thu, Mar 08, 2007 at 05:25:55PM -0500, Christopher H. Laco wrote:
> Catalyst config support a 'local' config file in addition to the regular
> one. I'm not sure on the exact file name, but I think it's myapp_local.yml
That's also a shallow merge, IIRC. It just calls $c->config with the
local config.
I ended up with something like this -- at this time I only want to be able
to merge in my data represented as hashes.
sub deep_merge {
my ( $self, $config, $new_hash ) = @_;
for my $key ( keys %$new_hash ) {
my $value = $new_hash->{$key};
if ( ref $value eq 'HASH' ) {
$config->{$key} ||= {};
$self->deep_merge( $config->{$key}, $value );
} else {
$config->{$key} = $value;
}
}
}
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list