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
30 my ($self, $provides) = @_;
31 my $method_constructors = $self->method_constructors;
32 foreach my $key (keys %$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, %options) = @_;
49 if (exists $options{provides}) {
50 $self->_check_provides($options{provides});
51 $self->_process_options_for_provides(\%options);
55 after 'install_accessors' => sub {
57 my $class = $attr->associated_class;
59 my $method_constructors = $attr->method_constructors;
61 foreach my $key (keys %{$attr->provides}) {
63 $attr->provides->{$key},
64 $method_constructors->{$key}->($attr)
79 MooseX::AttributeHelpers::Base
89 All complex software has bugs lurking in it, and this module is no
90 exception. If you find a bug please either email me, or add the bug
95 Stevan Little E<lt>stevan@iinteractive.comE<gt>
97 =head1 COPYRIGHT AND LICENSE
99 Copyright 2007 by Infinity Interactive, Inc.
101 L<http://www.iinteractive.com>
103 This library is free software; you can redistribute it and/or modify
104 it under the same terms as Perl itself.