File Coverage

blib/lib/MooseX/ExtraArgs.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package MooseX::ExtraArgs;
2              
3             $MooseX::ExtraArgs::VERSION = '0.02';
4              
5             =head1 NAME
6              
7             MooseX::ExtraArgs - Save constructor arguments that were not consumed.
8              
9             =head1 SYNOPSIS
10              
11             Create a class that uses this module:
12              
13             package MyClass;
14             use Moose;
15             use MooseX::ExtraArgs;
16             has foo => ( is=>'ro', isa=>'Str' );
17            
18             my $object = MyClass->new( foo => 32, bar => 16 );
19             print $object->extra_args->{bar};
20              
21             =head1 DESCRIPTION
22              
23             This module provides access to any constructor arguments that were not assigned to an
24             attribute. Where L<MooseX::StrictConstructor> does not allow any unknown arguments, this
25             module expects unknown arguments and saves them for later access.
26              
27             This could be useful for proxy classes that expect extra arguments that will then be
28             used to pass as arguments to the underlying implementation.
29              
30             =cut
31              
32 1     1   183879 use Moose ();
  1         388000  
  1         34  
33 1     1   9 use Moose::Exporter;
  1         2  
  1         7  
34              
35             Moose::Exporter->setup_import_methods(
36             role_metaroles => {
37             application_to_class => ['MooseX::ExtraArgs::Meta::ToClass'],
38             application_to_role => ['MooseX::ExtraArgs::Meta::ToRole'],
39             },
40             base_class_roles => ['MooseX::ExtraArgs::Meta::Object'],
41             );
42              
43             1;
44             __END__
45              
46             =head1 AUTHOR
47              
48             Aran Clary Deltac <bluefeet@gmail.com>
49              
50             =head1 LICENSE
51              
52             This is free software; you can redistribute it and/or modify it under
53             the same terms as the Perl 5 programming language system itself.
54