1package MooX::Role::Parameterized::With;
2{
3    $MooX::Role::Parameterized::With::VERSION = '0.082';
4}
5use strict;
6use warnings;
7
8# ABSTRACT: MooX::Role::Parameterized:With - dsl to apply roles with composition parameters
9
10use Exporter;    # qw(import);
11use Module::Runtime qw(use_module);
12use List::MoreUtils qw(natatime);
13
14sub import {
15    my $package = shift;
16    my $target  = caller;
17
18    my $it = natatime( 2, @_ );
19
20    while ( my ( $role, $params ) = $it->() ) {
21        use_module($role)->apply( $params, target => $target );
22    }
23}
24
251;
26
27__END__
28
29=head1 NAME
30
31MooX::Role::Parameterized:With - dsl to apply roles with composition parameters
32
33=head1 SYNOPSYS
34
35    package FooWith;
36
37    use Moo;
38    use MooX::Role::Parameterized::With Bar => {
39        attr => 'baz',
40        method => 'run'
41    }, Other::Role => { ... };
42
43    has foo => ( is => 'ro');
44
45=head1 DESCRIPTION
46
47This B<experimental> package try to offer an easy way to add parametrized roles.
48
49Will load and apply L<MooX::Roles::Parameterized> roles, just need use this package
50with a hash of role => parameters.
51
52=head1 AUTHOR
53
54Tiago Peczenyj <tiago (dot) peczenyj (at) gmail (dot) com>
55
56=head1 BUGS
57
58Please report any bugs or feature requests on the bugtracker website
59