[libconfig-model-dpkg-perl] 18/23: tweak Dpkg::Backend to use Moose's "around"
dod at debian.org
dod at debian.org
Mon Feb 13 12:29:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
dod pushed a commit to branch master
in repository libconfig-model-dpkg-perl.
commit 3f0c6d0d8312647462833b7be1b9538669ade282
Author: Dominique Dumont <dod at debian.org>
Date: Wed Feb 1 19:07:53 2017 +0100
tweak Dpkg::Backend to use Moose's "around"
instead of bypassing Moose with call to SUPER
Also use a dispatch table to call special readers.
---
lib/Config/Model/Backend/Dpkg.pm | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/lib/Config/Model/Backend/Dpkg.pm b/lib/Config/Model/Backend/Dpkg.pm
index e95c748..76f1db9 100644
--- a/lib/Config/Model/Backend/Dpkg.pm
+++ b/lib/Config/Model/Backend/Dpkg.pm
@@ -7,28 +7,29 @@ use UNIVERSAL;
use Path::Tiny;
use File::Path;
use Log::Log4perl qw(get_logger :levels);
-use 5.10.1;
+use 5.20.1;
+
+use feature qw/postderef signatures/;
+no warnings qw/experimental::postderef experimental::signatures/;
extends 'Config::Model::Backend::PlainFile';
my $logger = get_logger("Backend::Dpkg::Root");
-sub read_hash {
- my ( $self, $obj, $elt, $file, $check, $args ) = @_;
+my %dispatch = (
+ patches => \&read_patch_series,
+);
- if ( $elt eq 'patches' ) {
- my $patch_dir = $args->{root} . $args->{config_dir} . "patches";
- $logger->info("Checking patches directory ($patch_dir)");
+around read_hash => sub ( $orig, $self, $obj, $elt, $file, $check, $args ) {
- $self->read_patch_series( $obj, $check, $patch_dir, $args );
- }
- else {
- $self->SUPER::read_hash(@_);
- }
-}
+ my $method = $dispatch{$elt} // $orig;
+
+ $self->$method( $obj, $elt, $file, $check, $args );
+};
-sub read_patch_series {
- my ( $self, $hash, $check, $patch_dir, $args ) = @_;
+sub read_patch_series ( $self, $hash, $elt, $file, $check, $args ) {
+ my $patch_dir = $args->{root} . $args->{config_dir} . "patches";
+ $logger->info("Checking patches directory ($patch_dir)");
my $series_files = "$patch_dir/series";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libconfig-model-dpkg-perl.git
More information about the Pkg-perl-cvs-commits
mailing list