• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/MooseX/H09-Feb-2017-378112

t/H09-Feb-2017-484375

xt/H09-Feb-2017-293204

CONTRIBUTING.mdH A D09-Feb-20174.1 KiB13287

ChangesH A D09-Feb-20173 KiB13866

INSTALLH A D09-Feb-20171.2 KiB4426

LICENSEH A D09-Feb-20178.8 KiB208154

MANIFESTH A D09-Feb-2017757 3837

META.jsonH A D09-Feb-201734.8 KiB1,0381,036

META.ymlH A D09-Feb-201722 KiB754753

Makefile.PLH A D09-Feb-20171.6 KiB7159

README.mdH A D09-Feb-20173.2 KiB10366

cpanfileH A D09-Feb-20171.7 KiB6155

dist.iniH A D09-Feb-2017303 1512

perlcriticrcH A D09-Feb-20171.9 KiB7149

perltidyrcH A D09-Feb-2017301 2322

tidyall.iniH A D09-Feb-2017561 2822

README.md

1# NAME
2
3MooseX::StrictConstructor - Make your object constructors blow up on unknown attributes
4
5# VERSION
6
7version 0.21
8
9# SYNOPSIS
10
11    package My::Class;
12
13    use Moose;
14    use MooseX::StrictConstructor;
15
16    has 'size' => ( is => 'ro' );
17
18    # then later ...
19
20    # this blows up because color is not a known attribute
21    My::Class->new( size => 5, color => 'blue' );
22
23# DESCRIPTION
24
25Simply loading this module makes your constructors "strict". If your
26constructor is called with an attribute init argument that your class does not
27declare, then it calls `Moose->throw_error()`. This is a great way to
28catch small typos.
29
30## Subverting Strictness
31
32You may find yourself wanting to have your constructor accept a
33parameter which does not correspond to an attribute.
34
35In that case, you'll probably also be writing a `BUILD()` or
36`BUILDARGS()` method to deal with that parameter. In a `BUILDARGS()`
37method, you can simply make sure that this parameter is not included
38in the hash reference you return. Otherwise, in a `BUILD()` method,
39you can delete it from the hash reference of parameters.
40
41    sub BUILD {
42        my $self   = shift;
43        my $params = shift;
44
45        if ( delete $params->{do_something} ) {
46            ...
47        }
48    }
49
50# BUGS
51
52Please report any bugs or feature requests to
53`bug-moosex-strictconstructor@rt.cpan.org`, or through the web
54interface at [http://rt.cpan.org](http://rt.cpan.org).  I will be notified, and then
55you'll automatically be notified of progress on your bug as I make
56changes.
57
58Bugs may be submitted at [https://github.com/moose/MooseX-StrictConstructor/issues](https://github.com/moose/MooseX-StrictConstructor/issues).
59
60I am also usually active on IRC as 'autarch' on `irc://irc.perl.org`.
61
62# SOURCE
63
64The source code repository for MooseX-StrictConstructor can be found at [https://github.com/moose/MooseX-StrictConstructor](https://github.com/moose/MooseX-StrictConstructor).
65
66# DONATIONS
67
68If you'd like to thank me for the work I've done on this module, please
69consider making a "donation" to me via PayPal. I spend a lot of free time
70creating free software, and would appreciate any support you'd care to offer.
71
72Please note that **I am not suggesting that you must do this** in order for me
73to continue working on this particular software. I will continue to do so,
74inasmuch as I have in the past, for as long as it interests me.
75
76Similarly, a donation made in this way will probably not make me work on this
77software much more, unless I get so many donations that I can consider working
78on free software full time (let's all have a chuckle at that together).
79
80To donate, log into PayPal and send money to autarch@urth.org, or use the
81button at [http://www.urth.org/~autarch/fs-donation.html](http://www.urth.org/~autarch/fs-donation.html).
82
83# AUTHOR
84
85Dave Rolsky <autarch@urth.org>
86
87# CONTRIBUTORS
88
89- Jesse Luehrs <doy@tozt.net>
90- Karen Etheridge <ether@cpan.org>
91- Ricardo Signes <rjbs@cpan.org>
92
93# COPYRIGHT AND LICENSE
94
95This software is Copyright (c) 2007 - 2017 by Dave Rolsky.
96
97This is free software, licensed under:
98
99    The Artistic License 2.0 (GPL Compatible)
100
101The full text of the license can be found in the
102`LICENSE` file included with this distribution.
103