From: Errietta Kostala Date: Tue, 19 Aug 2014 15:28:58 +0000 (+0100) Subject: Better config logic X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c68d9e18d8bcc980605bc5466ed8782a5cb5dcf8;p=scpubgit%2FApp-SCS.git Better config logic --- diff --git a/lib/App/SCS/Page.pm b/lib/App/SCS/Page.pm index 7c4350c..28edde4 100644 --- a/lib/App/SCS/Page.pm +++ b/lib/App/SCS/Page.pm @@ -17,16 +17,10 @@ sub _my_path { io->dir($_[0]->_top_dir)->catdir($_[0]->path) } with 'App::SCS::Role::PageChildren'; has $_ => (is => 'ro') for qw( - title subtitle description keywords plugins html created path + title subtitle description keywords html created path ); -has plugin_config => (is => 'lazy'); - -sub _build_plugin_config { - my ($self) = @_; - - return $self->plugins; -} +has plugin_config => (is => 'rw', 'required' => 1); sub has_plugin_config { exists $_[0]->plugin_config->{$_[1]} } @@ -41,7 +35,7 @@ sub with_plugin_config { : ($name, $config) ); } - return $self->with(plugins => pond_write_datum(\@new)); + return $self->with(plugin_config => \@new); } has _raw_page_plugins => (is => 'lazy', builder => sub { diff --git a/lib/App/SCS/PageSet.pm b/lib/App/SCS/PageSet.pm index 731f493..fdaf442 100644 --- a/lib/App/SCS/PageSet.pm +++ b/lib/App/SCS/PageSet.pm @@ -111,12 +111,16 @@ sub _inflate { } my $raw = $io->all; try { + my $extracted = $self->${\"_extract_from_${type}"}($raw); my $jsony = JSONY->new; - my $config = reduce { merge($a, $jsony->load($b->all)) } {}, @$config_files; + my $config = reduce { merge($a, $jsony->load($b->all)) } [], @$config_files; $extracted->{plugins} = pond_read_datum('[' . $extracted->{plugins} . ']'); - my $setup = merge($extracted, $config); + + my $setup = $extracted; + + $setup->{plugin_config} = merge($extracted->{plugins}, $config); try { my $tmp_cache = io($cache_name . ".tmp");