1MooseX::MultiInitArg(3pUms)er Contributed Perl DocumentatMiooonseX::MultiInitArg(3pm)
2
3
4
6 MooseX::MultiInitArg - Attributes with aliases for constructor
7 arguments.
8
10 package Thinger;
11 use Moose;
12 use MooseX::MultiInitArg;
13
14 has 'data' => (
15 metaclass => 'MultiInitArg',
16
17 # For composability, you could use the following:
18 # traits => ['MooseX::MultiInitArg::Trait'],
19
20 is => 'ro',
21 isa => 'Str',
22 init_args => [qw(munge frobnicate)],
23 );
24
25 package main;
26
27 # All these are equivalent
28 my $foo = Thinger->new(data => 'foo');
29 my $foo = Thinger->new(munge => 'foo');
30 my $foo = Thinger->new(frobnicate => 'foo');
31
33 If you've ever wanted to be able to call an attribute any number of
34 things while you're passing arguments to your object constructor, Now
35 You Can.
36
37 The primary motivator is that I have some attributes that were named
38 inconsistently, and I wanted to rename them without breaking backwards
39 compatibility with my existing API.
40
42 Paul Driver, "<frodwith at cpan.org>"
43
45 Copyright 2007-2013 by Paul Driver.
46
47 This library is free software; you can redistribute it and/or modify it
48 under the same terms as Perl itself.
49
50
51
52perl v5.28.1 2013-06-09 MooseX::MultiInitArg(3pm)