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.01';
4             }
5 1     1   51160 use Moose ();
  1         396446  
  1         32  
6 1     1   10 use Moose::Exporter;
  1         3  
  1         5  
7              
8             =head1 NAME
9              
10             MooseX::ExtraArgs - Save constructor arguments that were not consumed.
11              
12             =head1 SYNOPSIS
13              
14             Create a class that uses this module:
15              
16             package MyClass;
17             use Moose;
18             use MooseX::ExtraArgs;
19             has foo => ( is=>'ro', isa=>'Str' );
20            
21             my $object = MyClass->new( foo => 32, bar => 16 );
22             print $object->extra_args->{bar};
23              
24             =head1 DESCRIPTION
25              
26             This module provides access to any constructor arguments that were not assigned to an
27             attribute. Where L<MooseX::StrictConstructor> does not allow any unknown arguments, this
28             module expects unknown arguments and saves them for later access.
29              
30             This could be useful for proxy classes that expect extra arguments that will then be
31             used to pass as arguments to the underlying implementation.
32              
33             =cut
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