From: Matt S Trout Date: Thu, 28 Aug 2014 13:39:00 +0000 (+0000) Subject: clean up config merging X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d0194f50a27b5a920a0ef5e2d01bc524a08d10a8;p=scpubgit%2FApp-SCS.git clean up config merging --- diff --git a/Makefile.PL b/Makefile.PL index 824bec6..b87febd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -17,7 +17,6 @@ WriteMakefile( 'Try::Tiny' => 0, 'Plack::Middleware::SSI' => '0.12', 'JSON::MaybeXS' => 0, - 'Hash::Merge' => 0, 'JSONY' => 0, } ); diff --git a/lib/App/SCS/PageSet.pm b/lib/App/SCS/PageSet.pm index fb61a40..e44522c 100644 --- a/lib/App/SCS/PageSet.pm +++ b/lib/App/SCS/PageSet.pm @@ -11,7 +11,6 @@ use List::Util qw(reduce max); use Module::Runtime qw(use_module); use JSON::MaybeXS; use Moo; -use Hash::Merge qw(merge); use JSONY; with 'App::SCS::Role::PageChildren'; @@ -91,13 +90,16 @@ sub _inflate { my $extracted = $self->${\"_extract_from_${type}"}($raw); my $jsony = JSONY->new; - my $config = reduce { merge($a, $jsony->load($b->all)) } [], @config_files; - $extracted->{plugins} = $jsony->load($extracted->{plugins}); - - my $setup = $extracted; - - $setup->{plugin_config} = merge($extracted->{plugins}, $config); + my $setup = { + %$extracted, + plugin_config => [ + map @{$jsony->load($_)}, ( + $extracted->{plugins}, + (map $_->all, reverse @config_files), # apply config deepest first + ) + ] + }; try { my $tmp_cache = io($cache_name . ".tmp");