File Coverage

blib/lib/MooseX/MultiInitArg.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package MooseX::MultiInitArg;
2              
3 2     2   778981 use strict;
  2         8  
  2         239  
4 2     2   12 use warnings;
  2         3  
  2         118  
5              
6             our $VERSION = '0.02';
7              
8 2     2   367469 use MooseX::MultiInitArg::Attribute;
  2         7  
  2         97  
9 2     2   20 use MooseX::MultiInitArg::Trait;
  2         4  
  2         92  
10              
11             1;
12              
13             __END__
14              
15             =pod
16              
17             =head1 NAME
18              
19             MooseX::MultiInitArg - Attributes with aliases for constructor arguments.
20              
21             =head1 SYNOPSIS
22              
23             package Thinger;
24             use Moose;
25             use MooseX::MultiInitArg;
26            
27             has 'data' => (
28             metaclass => 'MultiInitArg',
29              
30             # For composability, you could use the following:
31             # traits => ['MooseX::MultiInitArg::Trait'],
32              
33             is => 'ro',
34             isa => 'Str',
35             init_args => [qw(munge frobnicate)],
36             );
37              
38             package main;
39              
40             # All these are equivalent
41             my $foo = Thinger->new(data => 'foo');
42             my $foo = Thinger->new(munge => 'foo');
43             my $foo = Thinger->new(frobnicate => 'foo');
44              
45             =head1 DESCRIPTION
46              
47             If you've ever wanted to be able to call an attribute any number of things
48             while you're passing arguments to your object constructor, Now You Can.
49              
50             The primary motivator is that I have some attributes that were named
51             inconsistently, and I wanted to rename them without breaking backwards
52             compatibility with my existing API.
53              
54             =head1 AUTHOR
55              
56             Paul Driver, C<< <frodwith at cpan.org> >>
57              
58             =head1 COPYRIGHT AND LICENSE
59              
60             Copyright 2007-2013 by Paul Driver.
61              
62             This library is free software; you can redistribute it and/or modify
63             it under the same terms as Perl itself.
64              
65             =cut
66