Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perigrin/moosex-private-attributes
Traits for Private Moose Attributes
https://github.com/perigrin/moosex-private-attributes
Last synced: 22 days ago
JSON representation
Traits for Private Moose Attributes
- Host: GitHub
- URL: https://github.com/perigrin/moosex-private-attributes
- Owner: perigrin
- Created: 2010-11-17T22:46:27.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2010-11-18T03:14:52.000Z (about 14 years ago)
- Last Synced: 2024-05-01T22:51:37.728Z (8 months ago)
- Language: Perl
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MooseX::Private::Attributes
21:06 <@mst> I write
21:06 <@mst> has '_foo' => (is => 'ro', init_arg => 'foo');
21:06 <@mst> far far too much
[...]
21:07 <@rjbs> I think my version of that is:
21:07 <@rjbs> has foo => (reader => '_foo');
[...]
21:08 * perigrin wonders if it wouldn't be worth the hour to sit down and write MosoeX::PrivateAccessors
21:08 <@perigrin> for is => 'private'
21:08 <@perigrin> that does rjbs' answer## Synopsis
package Foo;
use Moose;
use MooseX::Private::Attributes;has foo => ( # private
traits => ['Private'],
is => 'ro',
);has _bar => ( # private
is => 'ro',
);has baz => ( # private with a writer _baz
traits => ['Private'],
is => 'rw'
);1;
package main;
my $meta = Foo->meta;
say for $meta->get_private_attribute_list;
## DescriptionThis module does *not* create truely private accessors. Instead it is a way
of creating the `_foo` style idiom for Perl. It also adds a set of methods to
`Moose::Meta::Class` for finding private attributes easily.