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 read-only 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?
MooseX::AttributeShortcuts is a Perl module that 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.
SYNOPSIS
package Some::Class;
use Moose;
use MooseX::AttributeShortcuts;
# same as: is => 'ro', writer => '_set_foo'
has foo => (is => 'rwp');
# same as: is => 'ro', builder => '_build_bar'
has bar => (is => 'ro', builder => 1);
# same as: is => 'ro', clearer => 'clear_bar'
has bar => (is => 'ro', clearer => 1);
# same as: is => 'ro', predicate => 'has_bar'
has bar => (is => 'ro', predicate => 1);
# works as you'd expect for "private": predicate => '_has_bar'
has _bar => (is => 'ro', predicate => 1);
# or...
package Some::Other::Class;
use Moose;
use MooseX::AttributeShortcuts -writer_prefix => '_';
# same as: is => 'ro', writer => '_foo'
has foo => (is => 'rwp');
Product's homepage
Requirements:
· Perl