1 package MooseX::AlwaysCoerce;
6 use namespace::autoclean;
11 Moose::Exporter->setup_import_methods (
12 with_caller => [ 'has', 'class_has' ]
17 MooseX::AlwaysCoerce - Automatically enable coercions for Moose attributes
25 our $VERSION = '0.01';
32 use MooseX::ClassAttribute;
33 use MooseX::AlwaysCoerce;
34 use MyTypeLib 'SomeType';
36 has foo => (is => 'rw', isa => SomeType); # coerce => 1 automatically added
38 # same, but you must load MooseX::ClassAttribute *BEFORE*
39 # MooseX::AlwaysCoerce
40 class_has bar => (is => 'rw', isa => SomeType);
44 Have you ever spent an hour or more trying to figure out "WTF, why did my
45 coercion not run?" only to find out that you forgot C<< coerce => 1 >> ?
47 Just load this module in your L<Moose> class and C<< coerce => 1 >> will be
48 enabled for every attribute automatically.
53 push @_, (coerce => 1);
58 push @_, (coerce => 1);
59 goto &MooseX::ClassAttribute::class_has;
64 Rafael Kitover, C<< <rkitover at cpan.org> >>
68 Please report any bugs or feature requests to C<bug-moosex-alwayscoerce at rt.cpan.org>, or through
69 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-AlwaysCoerce>. I will be notified, and then you'll
70 automatically be notified of progress on your bug as I make changes.
74 You can find more information at:
78 =item * RT: CPAN's request tracker
80 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-AlwaysCoerce>
82 =item * AnnoCPAN: Annotated CPAN documentation
84 L<http://annocpan.org/dist/MooseX-AlwaysCoerce>
88 L<http://cpanratings.perl.org/d/MooseX-AlwaysCoerce>
92 L<http://search.cpan.org/dist/MooseX-AlwaysCoerce/>
96 =head1 ACKNOWLEDGEMENTS
98 My own stupidity, for inspiring me to write this module.
100 =head1 COPYRIGHT & LICENSE
102 Copyright (c) 2009 Rafael Kitover
104 This program is free software; you can redistribute it and/or modify it
105 under the same terms as Perl itself.
109 1; # End of MooseX::AlwaysCoerce