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} || exists $params{alias} ) {
27 # Moose::Deprecated::deprecated(
28 # feature => 'alias or excludes',
30 # "The alias and excludes options for role application have been renamed -alias and -excludes"
34 if ( exists $params{excludes} && !exists $params{'-excludes'} ) {
35 $params{'-excludes'} = delete $params{excludes};
37 if ( exists $params{alias} && !exists $params{'-alias'} ) {
38 $params{'-alias'} = delete $params{alias};
41 if ( exists $params{'-excludes'} ) {
43 # I wish we had coercion here :)
44 $params{'-excludes'} = (
45 ref $params{'-excludes'} eq 'ARRAY'
46 ? $params{'-excludes'}
47 : [ $params{'-excludes'} ]
51 $class->_new(\%params);
54 sub is_method_excluded {
55 my ($self, $method_name) = @_;
56 foreach (@{$self->get_method_exclusions}) {
57 return 1 if $_ eq $method_name;
62 sub is_method_aliased {
63 my ($self, $method_name) = @_;
64 exists $self->get_method_aliases->{$method_name} ? 1 : 0
67 sub is_aliased_method {
68 my ($self, $method_name) = @_;
69 my %aliased_names = reverse %{$self->get_method_aliases};
70 exists $aliased_names{$method_name} ? 1 : 0;
76 $self->check_role_exclusions(@_);
77 $self->check_required_methods(@_);
78 $self->check_required_attributes(@_);
80 $self->apply_attributes(@_);
81 $self->apply_methods(@_);
83 $self->apply_override_method_modifiers(@_);
85 $self->apply_before_method_modifiers(@_);
86 $self->apply_around_method_modifiers(@_);
87 $self->apply_after_method_modifiers(@_);
90 sub check_role_exclusions { Carp::croak "Abstract Method" }
91 sub check_required_methods { Carp::croak "Abstract Method" }
92 sub check_required_attributes { Carp::croak "Abstract Method" }
94 sub apply_attributes { Carp::croak "Abstract Method" }
95 sub apply_methods { Carp::croak "Abstract Method" }
96 sub apply_override_method_modifiers { Carp::croak "Abstract Method" }
97 sub apply_method_modifiers { Carp::croak "Abstract Method" }
99 sub apply_before_method_modifiers { (shift)->apply_method_modifiers('before' => @_) }
100 sub apply_around_method_modifiers { (shift)->apply_method_modifiers('around' => @_) }
101 sub apply_after_method_modifiers { (shift)->apply_method_modifiers('after' => @_) }
111 Moose::Meta::Role::Application - A base class for role application
115 This is the abstract base class for role applications.
117 The API for this class and its subclasses still needs some
118 consideration, and is intentionally not yet documented.
128 =item B<get_method_exclusions>
130 =item B<is_method_excluded>
132 =item B<get_method_aliases>
134 =item B<is_aliased_method>
136 =item B<is_method_aliased>
140 =item B<check_role_exclusions>
142 =item B<check_required_methods>
144 =item B<check_required_attributes>
146 =item B<apply_attributes>
148 =item B<apply_methods>
150 =item B<apply_method_modifiers>
152 =item B<apply_before_method_modifiers>
154 =item B<apply_after_method_modifiers>
156 =item B<apply_around_method_modifiers>
158 =item B<apply_override_method_modifiers>
164 See L<Moose/BUGS> for details on reporting bugs.
168 Stevan Little E<lt>stevan@iinteractive.comE<gt>
170 =head1 COPYRIGHT AND LICENSE
172 Copyright 2006-2010 by Infinity Interactive, Inc.
174 L<http://www.iinteractive.com>
176 This library is free software; you can redistribute it and/or modify
177 it under the same terms as Perl itself.