1 package Moose::Meta::Role::Application;
8 $VERSION = eval $VERSION;
9 our $AUTHORITY = 'cpan:STEVAN';
11 __PACKAGE__->meta->add_attribute('method_exclusions' => (
12 init_arg => 'excludes',
13 reader => 'get_method_exclusions',
17 __PACKAGE__->meta->add_attribute('method_aliases' => (
19 reader => 'get_method_aliases',
24 my ($class, %params) = @_;
26 if (exists $params{excludes}) {
27 # I wish we had coercion here :)
28 $params{excludes} = (ref $params{excludes} eq 'ARRAY'
30 : [ $params{excludes} ]);
33 $class->_new(\%params);
36 sub is_method_excluded {
37 my ($self, $method_name) = @_;
38 foreach (@{$self->get_method_exclusions}) {
39 return 1 if $_ eq $method_name;
44 sub is_method_aliased {
45 my ($self, $method_name) = @_;
46 exists $self->get_method_aliases->{$method_name} ? 1 : 0
49 sub is_aliased_method {
50 my ($self, $method_name) = @_;
51 my %aliased_names = reverse %{$self->get_method_aliases};
52 exists $aliased_names{$method_name} ? 1 : 0;
58 $self->check_role_exclusions(@_);
59 $self->check_required_methods(@_);
60 $self->check_required_attributes(@_);
62 $self->apply_attributes(@_);
63 $self->apply_methods(@_);
65 $self->apply_override_method_modifiers(@_);
67 $self->apply_before_method_modifiers(@_);
68 $self->apply_around_method_modifiers(@_);
69 $self->apply_after_method_modifiers(@_);
72 sub check_role_exclusions { Carp::croak "Abstract Method" }
73 sub check_required_methods { Carp::croak "Abstract Method" }
74 sub check_required_attributes { Carp::croak "Abstract Method" }
76 sub apply_attributes { Carp::croak "Abstract Method" }
77 sub apply_methods { Carp::croak "Abstract Method" }
78 sub apply_override_method_modifiers { Carp::croak "Abstract Method" }
79 sub apply_method_modifiers { Carp::croak "Abstract Method" }
81 sub apply_before_method_modifiers { (shift)->apply_method_modifiers('before' => @_) }
82 sub apply_around_method_modifiers { (shift)->apply_method_modifiers('around' => @_) }
83 sub apply_after_method_modifiers { (shift)->apply_method_modifiers('after' => @_) }
93 Moose::Meta::Role::Application - A base class for role application
97 This is the abstract base class for role applications.
107 =item B<get_method_exclusions>
109 =item B<is_method_excluded>
111 =item B<get_method_aliases>
113 =item B<is_aliased_method>
115 =item B<is_method_aliased>
119 =item B<check_role_exclusions>
121 =item B<check_required_methods>
123 =item B<check_required_attributes>
125 =item B<apply_attributes>
127 =item B<apply_methods>
129 =item B<apply_method_modifiers>
131 =item B<apply_before_method_modifiers>
133 =item B<apply_after_method_modifiers>
135 =item B<apply_around_method_modifiers>
137 =item B<apply_override_method_modifiers>
143 All complex software has bugs lurking in it, and this module is no
144 exception. If you find a bug please either email me, or add the bug
149 Stevan Little E<lt>stevan@iinteractive.comE<gt>
151 =head1 COPYRIGHT AND LICENSE
153 Copyright 2006-2008 by Infinity Interactive, Inc.
155 L<http://www.iinteractive.com>
157 This library is free software; you can redistribute it and/or modify
158 it under the same terms as Perl itself.