1 package MooseX::Policy::SemiAffordanceAccessor;
7 our $AUTHORITY = 'cpan:DROLSKY';
9 use constant attribute_metaclass => 'MooseX::Policy::SemiAffordanceAccessor::Attribute';
12 package MooseX::Policy::SemiAffordanceAccessor::Attribute;
16 extends 'Moose::Meta::Attribute';
18 before '_process_options' => sub
24 if ( exists $options->{is} &&
25 ! ( exists $options->{reader} || exists $options->{writer} ) )
27 if ( $options->{is} eq 'ro' )
29 $options->{reader} = $name;
31 elsif ( $options->{is} eq 'rw' )
33 $options->{reader} = $name;
36 if ( $name =~ s/^_// )
41 $options->{writer} = $prefix . q{_} . $name;
44 delete $options->{is};
57 MooseX::Policy::SemiAffordanceAccessor - A policy to name accessors foo() and set_foo()
61 use Moose::Policy 'MooseX::Policy::SemiAffordanceAccessor';
64 # make some attributes
68 This class does not provide any methods. Just loading it changes the
69 default naming policy for the package so that accessors are separated
70 into get and set methods. The get methods have the same name as the
71 accessor, while set methods are prefixed with "set_".
73 If you define an attribute with a leading underscore, then the set
74 method will start with "_set_".
76 The name "semi-affordance" comes from David Wheeler's Class::Meta
81 Dave Rolsky, C<< <autarch@urth.org> >>
85 Please report any bugs or feature requests to
86 C<bug-moosex-policy-semiaffordanceaccessor@rt.cpan.org>, or through
87 the web interface at L<http://rt.cpan.org>. I will be notified, and
88 then you'll automatically be notified of progress on your bug as I
91 =head1 COPYRIGHT & LICENSE
93 Copyright 2007 Dave Rolsky, All Rights Reserved.
95 This program is free software; you can redistribute it and/or modify
96 it under the same terms as Perl itself.