Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
rsrchboy committed May 4, 2017
1 parent 7260c22 commit bb623d0
Showing 1 changed file with 29 additions and 38 deletions.
67 changes: 29 additions & 38 deletions README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MooseX::AttributeShortcuts - Shorthand for common attribute options

# VERSION

This document describes version 0.029 of MooseX::AttributeShortcuts - released September 26, 2016 as part of MooseX-AttributeShortcuts.
This document describes version 0.029 of MooseX::AttributeShortcuts - released May 03, 2017 as part of MooseX-AttributeShortcuts.

# SYNOPSIS

Expand Down Expand Up @@ -61,6 +61,33 @@ 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.

## Some Notes On History

Moose has long had a [lazy\_build attribute option](https://metacpan.org/pod/Moose#lazy_build). It was
once considered a best practice, but that has, ah, changed. This trait began
as a desire to still leverage bits of `lazy_build` (and a tacit
acknowledgment that fat-finger bugs rank among the most embarrassing, right up
there with "the TV was unplugged the entire time").

This author does not recommend you use lazy\_build, unless you know exactly
what you're doing (probably) and that it's a good idea (probably not).

Nonetheless, this `lazy_build` option is why we set certain options the way
we do below; while `lazy_build` in its entirety is not optimal, it had the right
idea: regular, predictable accessor names for regular, predictable attribute
options.

As an example, just looking at the below it doesn't seem logical that:

has _foo => (is => 'ro', clearer => 1);

...becomes:

has _foo => (is => 'ro', clearer => '_clear_foo');

After reading the [lazy\_build attribute option](https://metacpan.org/pod/Moose#lazy_build),
however, we see that the choice had already been made for us.

# USAGE

This package automatically applies an attribute metaclass trait. Unless you
Expand All @@ -75,25 +102,6 @@ will help you apply this to the extended attribute:

has '+something' => (traits => [Shortcuts], ...);

# PREFIXES

We accept two parameters on the use of this module; they impact how builders
and writers are named.

## -writer\_prefix

use MooseX::::AttributeShortcuts -writer_prefix => 'prefix';

The default writer prefix is '\_set\_'. If you'd prefer it to be something
else (say, '\_'), this is where you'd do that.

## -builder\_prefix

use MooseX::::AttributeShortcuts -builder_prefix => 'prefix';

The default builder prefix is '\_build\_', as this is what lazy\_build does, and
what people in general recognize as build methods.

# NEW ATTRIBUTE OPTIONS

Unless specified here, all options defined by [Moose::Meta::Attribute](https://metacpan.org/pod/Moose::Meta::Attribute) and
Expand Down Expand Up @@ -181,7 +189,7 @@ Specifying `predicate => 1` will cause the following options to be set:

or, if your attribute name begins with an underscore:

predicate => "_has_$name"
predicate => "_has$name"

(that is, an attribute named "\_foo" would get "\_has\_foo")

Expand Down Expand Up @@ -374,23 +382,6 @@ feature.

Chris Weyl <cweyl@alumni.drew.edu>

## I'm a material boy in a material world

<div>
<a href="https://gratipay.com/RsrchBoy/"><img src="http://img.shields.io/gratipay/RsrchBoy.svg" /></a>
<a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a>
<a href="https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-attributeshortcuts&title=RsrchBoy's%20CPAN%20MooseX-AttributeShortcuts&tags=%22RsrchBoy's%20MooseX-AttributeShortcuts%20in%20the%20CPAN%22"><img src="http://api.flattr.com/button/flattr-badge-large.png" /></a>
</div>

Please note **I do not expect to be gittip'ed or flattr'ed for this work**,
rather **it is simply a very pleasant surprise**. I largely create and release
works like this because I need them or I find it enjoyable; however, don't let
that stop you if you feel like it ;)

[Flattr](https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fmoosex-attributeshortcuts&title=RsrchBoy&#x27;s%20CPAN%20MooseX-AttributeShortcuts&tags=%22RsrchBoy&#x27;s%20MooseX-AttributeShortcuts%20in%20the%20CPAN%22),
[Gratipay](https://gratipay.com/RsrchBoy/), or indulge my
[Amazon Wishlist](http://bit.ly/rsrchboys-wishlist)... If and \*only\* if you so desire.

# CONTRIBUTORS

- David Steinbrunner <dsteinbrunner@pobox.com>
Expand Down

0 comments on commit bb623d0

Please sign in to comment.