MooseX::AttributeShortcuts - Shorthand for common attribute options
package Some::Class; use Moose; use MooseX::AttributeShortcuts; # same as: is => 'ro', writer => '_foo' has foo => (is => 'rwp'); # same as: is => 'ro', builder => '_build_bar' has bar => (is => 'ro', builder => 1);
Ever find yourself repeatedly specifing writers and builders, because there's no good shortcut to specifying them? Sometimes you want an attribute to have a ro public interface, but a private writer. And wouldn't it be easier to just say "builder => 1" and have the attribute construct the canonical "_build_$name" builder name for you?
This package causes an attribute trait to be applied to all attributes defined to the using class. This trait extends the attribute option processing to handle the above variations.
Want to see additional options? Ask, or better yet, fork on GitHub and send a pull request.
For the following, "$name" should be read as the attribute name.
Specifing is => 'rwp' will cause the following options to be set:
is => 'ro' writer => "_$name"
Specifying builder => 1 will cause the following options to be set:
builder => "_build_$name"
All complex software has bugs lurking in it, and this module is no exception.
Please report any bugs to "email@example.com", or through the web interface at <http://rt.cpan.org>.
Chris Weyl <firstname.lastname@example.org>
This software is Copyright (c) 2011 by Chris Weyl.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999