882550367f9382ee31014e5798c980a39fffa1a2
[gitmo/MooseX-SemiAffordanceAccessor.git] / lib / MooseX / SemiAffordanceAccessor.pm
1 package MooseX::SemiAffordanceAccessor;
2
3 use strict;
4 use warnings;
5
6 our $VERSION = '0.05';
7
8 use Moose 0.84 ();
9 use Moose::Exporter;
10 use Moose::Util::MetaRole;
11 use MooseX::SemiAffordanceAccessor::Role::Attribute;
12
13 # The main reason to use this is to ensure that we get the right value
14 # in $p{for_class} later.
15 Moose::Exporter->setup_import_methods();
16
17 sub init_meta {
18     shift;
19     my %p = @_;
20
21     Moose->init_meta(%p);
22
23     return Moose::Util::MetaRole::apply_metaclass_roles(
24         for_class => $p{for_class},
25         attribute_metaclass_roles =>
26             ['MooseX::SemiAffordanceAccessor::Role::Attribute'],
27     );
28 }
29
30 1;
31
32 __END__
33
34 =pod
35
36 =head1 NAME
37
38 MooseX::SemiAffordanceAccessor - Name your accessors foo() and set_foo()
39
40 =head1 SYNOPSIS
41
42     use MooseX::SemiAffordanceAccessor;
43     use Moose;
44
45     # make some attributes
46
47 =head1 DESCRIPTION
48
49 This module does not provide any methods. Simply loading it changes
50 the default naming policy for the loading class so that accessors are
51 separated into get and set methods. The get methods have the same name
52 as the accessor, while set methods are prefixed with "set_".
53
54 If you define an attribute with a leading underscore, then the set
55 method will start with "_set_".
56
57 If you explicitly set a "reader" or "writer" name when creating an
58 attribute, then that attribute's naming scheme is left unchanged.
59
60 The name "semi-affordance" comes from David Wheeler's Class::Meta
61 module.
62
63 =head1 AUTHOR
64
65 Dave Rolsky, C<< <autarch@urth.org> >>
66
67 =head1 BUGS
68
69 Please report any bugs or feature requests to
70 C<bug-moosex-semiaffordanceaccessor@rt.cpan.org>, or through
71 the web interface at L<http://rt.cpan.org>.  I will be notified, and
72 then you'll automatically be notified of progress on your bug as I
73 make changes.
74
75 =head1 COPYRIGHT & LICENSE
76
77 Copyright 2007-2008 Dave Rolsky, All Rights Reserved.
78
79 This program is free software; you can redistribute it and/or modify
80 it under the same terms as Perl itself.
81
82 =cut