<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Dist::Zilla::Util::ConfigDumper - Easy implementation of 'dumpconfig'

VERSION
    version 0.003006

SYNOPSIS
      ...

      with 'Dist::Zilla::Role::Plugin';
      use Dist::Zilla::Util::ConfigDumper qw( config_dumper );

      around dump_config =&gt; config_dumper( __PACKAGE__, qw( foo bar baz ) );

FUNCTIONS
  "config_dumper"
      config_dumper( __PACKAGE__, qw( method list ) );

    Returns a function suitable for use with "around dump_config".

      my $sub = config_dumper( __PACKAGE__, qw( method list ) );
      around dump_config =&gt; $sub;

    Or

      around dump_config =&gt; sub {
        my ( $orig, $self, @args ) = @_;
        return config_dumper(__PACKAGE__, qw( method list ))-&gt;( $orig, $self, @args );
      };

    Either way:

      my $function = config_dumper( $package_name_for_config, qw( methods to call on $self ));
      my $hash = $function-&gt;( $function_that_returns_a_hash, $instance_to_call_methods_on, @somethinggoeshere );

    =~ All of this approximates:

      around dump_config =&gt; sub {
        my ( $orig , $self , @args ) = @_;
        my $conf = $self-&gt;$orig( @args );
        my $payload = {};

        for my $method ( @methods ) {
          try {
            $payload-&gt;{ $method } = $self-&gt;$method();
          };
        }
        $config-&gt;{+__PACKAGE__} = $payload;
      }

    Except with some extra "things dun goofed" handling.

  "dump_plugin"
    This function serves the other half of the equation, emulating "dzil"'s
    own internal behavior for extracting the "plugin" configuration data.

      for my $plugin ( @{ $zilla-&gt;plugins } ) {
        pp( dump_plugin( $plugin )); # could prove useful somewhere.
      }

    Its not usually something you need, but its useful in:

    *   Tests

    *   Crazy Stuff like injecting plugins

    *   Crazy Stuff like having "Child" plugins

    This serves to be a little more complicated than merely calling
    "-&gt;dump_config", as the structure "dzil" uses is:

      {
        class   =&gt; ...
        name    =&gt; ...
        version =&gt; ...
        config  =&gt; $dump_config_results_here
      }

    And of course, there's a bunch of magic stuff with "meta", "can" and "if
    keys %$configresults"

    All that insanity is wrapped in this simple interface.

ADVANCED USE
  CALLBACKS
    Internally

      config_dumper( $pkg, qw( method list ) );

    Maps to a bunch of subs, so its more like:

      config_dumper( $pkg, sub {
        my ( $instance, $payload ) = @_;
        $payload-&gt;{'method'} = $instance-&gt;method;
      }, sub {
        $_[1]-&gt;{'list'} = $_[0]-&gt;list;
      });

    So if you want to use that because its more convenient for some problem,
    be my guest.

      around dump_config =&gt; config_dumper( __PACKAGE__, sub {
        $_[1]-&gt;{'x'} = 'y'
      });

    is much less ugly than

      around dump_config =&gt; sub {
        my ( $orig, $self, @args ) = @_;
        my $conf = $self-&gt;$orig(@args);
        $config-&gt;{+__PACKAGE__} = { # if you forget the +, things break
           'x' =&gt; 'y'
        };
        return $config;
      };

  DETAILED CONFIGURATION
    There's an additional feature for advanced people:

      config_dumper( $pkg, \%config );

   "attrs"
      config_dumper( $pkg, { attrs =&gt; [qw( foo bar baz )] });

    This is for cases where you want to deal with "Moose" attributes, but
    want added safety of NOT loading attributes that have no value yet.

    For each item in "attrs", we'll call "Moose" attribute internals to
    determine if the attribute named has a value, and only then will we
    fetch it.

AUTHOR
    Kent Fredric &lt;kentnl@cpan.org&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2014 by Kent Fredric
    &lt;kentfredric@gmail.com&gt;.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

</pre></body></html>