2 package MooseX::AttributeHelpers::Base;
6 our $AUTHORITY = 'cpan:STEVAN';
8 extends 'Moose::Meta::Attribute';
10 has 'method_constructors' => (
22 # extend the parents stuff to make sure
23 # certain bits are now required ...
24 has '+$!default' => (required => 1);
25 has '+type_constraint' => (required => 1);
27 # this confirms that provides has
28 # all valid possibilities in it
31 my $method_constructors = $self->method_constructors;
32 foreach my $key (keys %{$self->provides}) {
33 (exists $method_constructors->{$key})
34 || confess "$key is an unsupported method type";
38 # this provides an opportunity to
39 # manipulate the %options to handle
40 # some of the provides features
42 sub _process_options_for_provides {
43 my ($self, $options) = @_;
47 before '_process_options' => sub {
48 my ($self, $name, $options) = @_;
49 if (exists $options->{provides}) {
50 $self->_process_options_for_provides($options);
54 after 'install_accessors' => sub {
56 my $class = $attr->associated_class;
58 # before we install them, lets
59 # make sure they are valid
60 $attr->_check_provides;
62 my $method_constructors = $attr->method_constructors;
64 foreach my $key (keys %{$attr->provides}) {
66 $attr->provides->{$key},
67 $method_constructors->{$key}->($attr)
82 MooseX::AttributeHelpers::Base
92 All complex software has bugs lurking in it, and this module is no
93 exception. If you find a bug please either email me, or add the bug
98 Stevan Little E<lt>stevan@iinteractive.comE<gt>
100 =head1 COPYRIGHT AND LICENSE
102 Copyright 2007 by Infinity Interactive, Inc.
104 L<http://www.iinteractive.com>
106 This library is free software; you can redistribute it and/or modify
107 it under the same terms as Perl itself.