Remove some useless comments
[gitmo/Moose.git] / lib / Moose / Meta / Role / Application.pm
CommitLineData
fb1e11d5 1package Moose::Meta::Role::Application;
2
3use strict;
4use warnings;
5use metaclass;
6
9039e8ec 7our $VERSION = '0.89_01';
75b95414 8$VERSION = eval $VERSION;
fb1e11d5 9our $AUTHORITY = 'cpan:STEVAN';
10
c4538447 11__PACKAGE__->meta->add_attribute('method_exclusions' => (
c8b8d92f 12 init_arg => '-excludes',
c4538447 13 reader => 'get_method_exclusions',
14 default => sub { [] }
15));
16
3e19778d 17__PACKAGE__->meta->add_attribute('method_aliases' => (
c8b8d92f 18 init_arg => '-alias',
3e19778d 19 reader => 'get_method_aliases',
20 default => sub { {} }
21));
22
d03bd989 23sub new {
c4538447 24 my ($class, %params) = @_;
d03bd989 25
c8b8d92f 26 if (exists $params{excludes} && !exists $params{'-excludes'}) {
27 $params{'-excludes'} = delete $params{excludes};
28 }
29 if (exists $params{alias} && !exists $params{'-alias'}) {
30 $params{'-alias'} = delete $params{alias};
31 }
32
33 if (exists $params{'-excludes'}) {
c4538447 34 # I wish we had coercion here :)
c8b8d92f 35 $params{'-excludes'} = (ref $params{'-excludes'} eq 'ARRAY'
36 ? $params{'-excludes'}
37 : [ $params{'-excludes'} ]);
c4538447 38 }
d03bd989 39
1b8d1399 40 $class->_new(\%params);
c4538447 41}
42
43sub is_method_excluded {
44 my ($self, $method_name) = @_;
45 foreach (@{$self->get_method_exclusions}) {
46 return 1 if $_ eq $method_name;
47 }
48 return 0;
49}
fb1e11d5 50
3e19778d 51sub is_method_aliased {
52 my ($self, $method_name) = @_;
53 exists $self->get_method_aliases->{$method_name} ? 1 : 0
54}
55
56sub is_aliased_method {
57 my ($self, $method_name) = @_;
58 my %aliased_names = reverse %{$self->get_method_aliases};
59 exists $aliased_names{$method_name} ? 1 : 0;
60}
61
fb1e11d5 62sub apply {
1c9db35c 63 my $self = shift;
fb1e11d5 64
1c9db35c 65 $self->check_role_exclusions(@_);
66 $self->check_required_methods(@_);
709c321c 67 $self->check_required_attributes(@_);
d03bd989 68
1c9db35c 69 $self->apply_attributes(@_);
d03bd989 70 $self->apply_methods(@_);
71
1c9db35c 72 $self->apply_override_method_modifiers(@_);
d03bd989 73
1c9db35c 74 $self->apply_before_method_modifiers(@_);
75 $self->apply_around_method_modifiers(@_);
76 $self->apply_after_method_modifiers(@_);
fb1e11d5 77}
78
547dda77 79sub check_role_exclusions { Carp::croak "Abstract Method" }
80sub check_required_methods { Carp::croak "Abstract Method" }
81sub check_required_attributes { Carp::croak "Abstract Method" }
82
83sub apply_attributes { Carp::croak "Abstract Method" }
84sub apply_methods { Carp::croak "Abstract Method" }
85sub apply_override_method_modifiers { Carp::croak "Abstract Method" }
86sub apply_method_modifiers { Carp::croak "Abstract Method" }
bca01282 87
88sub apply_before_method_modifiers { (shift)->apply_method_modifiers('before' => @_) }
89sub apply_around_method_modifiers { (shift)->apply_method_modifiers('around' => @_) }
90sub apply_after_method_modifiers { (shift)->apply_method_modifiers('after' => @_) }
fb1e11d5 91
921;
93
94__END__
95
96=pod
97
98=head1 NAME
99
ab76842e 100Moose::Meta::Role::Application - A base class for role application
fb1e11d5 101
102=head1 DESCRIPTION
103
104This is the abstract base class for role applications.
105
a5583b3a 106The API for this class and its subclasses still needs some
107consideration, and is intentionally not yet documented.
108
fb1e11d5 109=head2 METHODS
110
111=over 4
112
113=item B<new>
114
115=item B<meta>
116
c4538447 117=item B<get_method_exclusions>
118
119=item B<is_method_excluded>
120
3e19778d 121=item B<get_method_aliases>
122
123=item B<is_aliased_method>
124
125=item B<is_method_aliased>
126
fb1e11d5 127=item B<apply>
128
709c321c 129=item B<check_role_exclusions>
130
fb1e11d5 131=item B<check_required_methods>
132
709c321c 133=item B<check_required_attributes>
fb1e11d5 134
135=item B<apply_attributes>
136
137=item B<apply_methods>
138
139=item B<apply_method_modifiers>
140
141=item B<apply_before_method_modifiers>
142
143=item B<apply_after_method_modifiers>
144
145=item B<apply_around_method_modifiers>
146
147=item B<apply_override_method_modifiers>
148
149=back
150
151=head1 BUGS
152
153All complex software has bugs lurking in it, and this module is no
154exception. If you find a bug please either email me, or add the bug
155to cpan-RT.
156
157=head1 AUTHOR
158
159Stevan Little E<lt>stevan@iinteractive.comE<gt>
160
161=head1 COPYRIGHT AND LICENSE
162
2840a3b2 163Copyright 2006-2009 by Infinity Interactive, Inc.
fb1e11d5 164
165L<http://www.iinteractive.com>
166
167This library is free software; you can redistribute it and/or modify
168it under the same terms as Perl itself.
169
170=cut
171