Skip to content

Commit

Permalink
v0.033
Browse files Browse the repository at this point in the history
	* Detect if MooseX::SemiAffordanceAccessor has been applied to the
	  attribute, and conform our behaviour to it if necessary.  Add some docs,
	  tests around this.
  • Loading branch information
rsrchboy committed Jul 25, 2017
1 parent 0ac2e74 commit c6eb9a7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Revision history for MooseX-AttributeShortcuts

{{$NEXT}}

0.033 2017-07-24 21:52:45 CDT-0500
* Detect if MooseX::SemiAffordanceAccessor has been applied to the
attribute, and conform our behaviour to it if necessary. Add some docs,
tests around this.
Expand Down
45 changes: 34 additions & 11 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.032 of MooseX::AttributeShortcuts - released June 13, 2017 as part of MooseX-AttributeShortcuts.
This document describes version 0.033 of MooseX::AttributeShortcuts - released July 24, 2017 as part of MooseX-AttributeShortcuts.

# SYNOPSIS

Expand Down Expand Up @@ -43,12 +43,6 @@ This document describes version 0.032 of MooseX::AttributeShortcuts - released J
# or...
package Some::Other::Class;

use Moose;
use MooseX::AttributeShortcuts -writer_prefix => '_';

# same as: is => 'ro', writer => '_foo'
has foo => (is => 'rwp');

# DESCRIPTION

Ever find yourself repeatedly specifying writers and builders, because there's
Expand Down Expand Up @@ -100,8 +94,8 @@ metaclasses.

If you're extending a class and trying to extend its attributes as well,
you'll find out that the trait is only applied to attributes defined locally
in the class. This package exports a trait shortcut function "Shortcuts" that
will help you apply this to the extended attribute:
in the class. This package exports a trait shortcut function `Shortcuts`
that will help you apply this to the extended attribute:

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

Expand All @@ -111,7 +105,7 @@ Unless specified here, all options defined by [Moose::Meta::Attribute](https://m
[Class::MOP::Attribute](https://metacpan.org/pod/Class::MOP::Attribute) remain unchanged.

Want to see additional options? Ask, or better yet, fork on GitHub and send
a pull request. If the shortcuts you're asking for already exist in [Moo](https://metacpan.org/pod/Moo) or
a pull request. If the shortcuts you're asking for already exist in [Moo](https://metacpan.org/pod/Moo) or
[Mouse](https://metacpan.org/pod/Mouse) or elsewhere, please note that as it will carry significant weight.

For the following, `$name` should be read as the attribute name; and the
Expand Down Expand Up @@ -375,12 +369,41 @@ coderefs that will coerce a given type to our type.
],
);

# INTERACTIONS WITH OTHER ATTRIBUTE TRAITS

Sometimes attribute traits interact in surprising ways. This trait is well
behaved; if you have discovered any interactions with other traits (good, bad,
indifferent, etc), please
[report this](https://github.com/RsrchBoy/moosex-attributeshortcuts/issues/new)
so that it can be worked around, fixed, or documented, as appropriate.

## MooseX::SemiAffordanceAccessor

[MooseX::SemiAffordanceAccessor](https://metacpan.org/pod/MooseX::SemiAffordanceAccessor) changes how the `is =` 'rw'> and
`accessor =` ...> attribute options work. If our trait detects that an
attribute has had the
[MooseX::SemiAffordanceAccessor attribute trait](https://metacpan.org/pod/MooseX::SemiAffordanceAccessor::Role::Attribute)
applied, then we change our behaviour to conform to its expectations:

- is => 'rwp'

This is now effectively equivalent to:

is => 'ro',
writer => '_set_...',

- `writer_prefix` is ignored

...as MooseX::SemiAffordanceAccessor has its own specific ideas as to how
writers should look.

# SEE ALSO

Please see those modules/websites for more information related to this module.

- [MooseX::Types](https://metacpan.org/pod/MooseX::Types)
- [Moo](https://metacpan.org/pod/Moo)
- [MooseX::Types](https://metacpan.org/pod/MooseX::Types)
- [MooseX::SemiAffordanceAccessor](https://metacpan.org/pod/MooseX::SemiAffordanceAccessor)

# BUGS

Expand Down

0 comments on commit c6eb9a7

Please sign in to comment.