NAME
MooseX::Role::DryRunnable - role for add a dry_run option into your Moose Class
SYNOPSIS
package Foo;
use Moose;
with 'MooseX::Role::DryRunnable' => {
methods => [ qw(bar) ]
};
has dry_run => (is => 'ro', isa => 'Bool', default => 0);
sub bar {
shift;
print "Foo::bar @_\n";
}
sub is_dry_run { # required !
shift->dry_run
}
sub on_dry_run { # required !
my $self = shift;
my $method = shift;
$self->logger("Dry Run method=$method, args: \n", @_);
}
DESCRIPTION
This module is a Moose Role who require two methods, `is_dry_run` and `on_dry_run`, the first method return true if we are in this mode (reading from a configuration file, command line option or some environment variable) and the second receive the name of the method and the list of arguments.
REQUIRES
is_dry_run
This method must return one boolean value. If true, we will execute the alternate code described in `on_dry_run`. You must implement!
on_dry_run
This method will receive the method name and all of the parameters form the original method. You must implement!
ROLE PARAMETERS
This Role is Parameterized, and we can choose the set of methods to apply the dry_run capability.
methods
This is the set of methods to be changed, can be a string, an array ref or a regular expression. Each method in this parameter will receive an extra code (using Moose 'around') to act as a Dry Run Method.
SEE ALSO
Moose::Role, MooseX::Role::Parameterized.
BUGS AND LIMITATIONS
There are no known bugs in this module.
Please report problems to Tiago Peczenyj <tiago.peczenyj@gmail.com>, or (preferred) to this package's RT tracker at <bug-MooseX-Role-DryRunnable@rt.cpan.org>.
AUTHOR
Tiago Peczenyj <tiago.peczenyj@gmail.com>
LICENSE AND COPYRIGHT
Copyright (c) 2013 Tiago Peczenyj <tiago.peczenyj@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.