[libdist-zilla-util-configdumper-perl] 03/04: move config_dumper docs up so function ordering is retained
Florian Schlichting
fsfs at moszumanska.debian.org
Sat Nov 11 15:43:52 UTC 2017
This is an automated email from the git hooks/post-receive script.
fsfs pushed a commit to annotated tag 0.003000-source
in repository libdist-zilla-util-configdumper-perl.
commit e4e1539480846e7fdc33165151cd373bd527a097
Author: Kent Fredric <kentfredric at gmail.com>
Date: Sun Aug 24 02:08:46 2014 +1200
move config_dumper docs up so function ordering is retained
---
lib/Dist/Zilla/Util/ConfigDumper.pm | 78 +++++++++++++++++++------------------
1 file changed, 40 insertions(+), 38 deletions(-)
diff --git a/lib/Dist/Zilla/Util/ConfigDumper.pm b/lib/Dist/Zilla/Util/ConfigDumper.pm
index 9590d24..f99b54b 100644
--- a/lib/Dist/Zilla/Util/ConfigDumper.pm
+++ b/lib/Dist/Zilla/Util/ConfigDumper.pm
@@ -15,6 +15,46 @@ use Carp qw( croak );
use Try::Tiny qw( try catch );
use Sub::Exporter::Progressive -setup => { exports => [qw( config_dumper )], };
+=function C<config_dumper>
+
+ config_dumper( __PACKAGE__, qw( method list ) );
+
+Returns a function suitable for use with C<around dump_config>.
+
+ my $sub = config_dumper( __PACKAGE__, qw( method list ) );
+ around dump_config => $sub;
+
+Or
+
+ around dump_config => sub {
+ my ( $orig, $self, @args ) = @_;
+ return config_dumper(__PACKAGE__, qw( method list ))->( $orig, $self, @args );
+ };
+
+Either way:
+
+ my $function = config_dumper( $package_name_for_config, qw( methods to call on $self ));
+ my $hash = $function->( $function_that_returns_a_hash, $instance_to_call_methods_on, @somethinggoeshere );
+
+=~ All of this approximates:
+
+ around dump_config => sub {
+ my ( $orig , $self , @args ) = @_;
+ my $conf = $self->$orig( @args );
+ my $payload = {};
+
+ for my $method ( @methods ) {
+ try {
+ $payload->{ $method } = $self->$method();
+ };
+ }
+ $config->{+__PACKAGE__} = $payload;
+ }
+
+Except with some extra "things dun goofed" handling.
+
+=cut
+
sub config_dumper {
my ( $package, @methodnames ) = @_;
my (@tests) = map { _mk_test( $package, $_ ) } @methodnames;
@@ -87,44 +127,6 @@ sub _mk_test {
1;
-=function C<config_dumper>
-
- config_dumper( __PACKAGE__, qw( method list ) );
-
-Returns a function suitable for use with C<around dump_config>.
-
- my $sub = config_dumper( __PACKAGE__, qw( method list ) );
- around dump_config => $sub;
-
-Or
-
- around dump_config => sub {
- my ( $orig, $self, @args ) = @_;
- return config_dumper(__PACKAGE__, qw( method list ))->( $orig, $self, @args );
- };
-
-Either way:
-
- my $function = config_dumper( $package_name_for_config, qw( methods to call on $self ));
- my $hash = $function->( $function_that_returns_a_hash, $instance_to_call_methods_on, @somethinggoeshere );
-
-=~ All of this approximates:
-
- around dump_config => sub {
- my ( $orig , $self , @args ) = @_;
- my $conf = $self->$orig( @args );
- my $payload = {};
-
- for my $method ( @methods ) {
- try {
- $payload->{ $method } = $self->$method();
- };
- }
- $config->{+__PACKAGE__} = $payload;
- }
-
-Except with some extra "things dun goofed" handling.
-
=head1 SYNOPSIS
...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-util-configdumper-perl.git
More information about the Pkg-perl-cvs-commits
mailing list