bump version to 1.25
[gitmo/Moose.git] / lib / Moose / Meta / Role / Application.pm
CommitLineData
fb1e11d5 1package Moose::Meta::Role::Application;
2
3use strict;
4use warnings;
5use metaclass;
6
0c3879e8 7our $VERSION = '1.25';
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) = @_;
1b8d1399 25 $class->_new(\%params);
c4538447 26}
27
28sub is_method_excluded {
29 my ($self, $method_name) = @_;
30 foreach (@{$self->get_method_exclusions}) {
31 return 1 if $_ eq $method_name;
32 }
33 return 0;
34}
fb1e11d5 35
3e19778d 36sub is_method_aliased {
37 my ($self, $method_name) = @_;
38 exists $self->get_method_aliases->{$method_name} ? 1 : 0
39}
40
41sub is_aliased_method {
42 my ($self, $method_name) = @_;
43 my %aliased_names = reverse %{$self->get_method_aliases};
44 exists $aliased_names{$method_name} ? 1 : 0;
45}
46
fb1e11d5 47sub apply {
1c9db35c 48 my $self = shift;
fb1e11d5 49
1c9db35c 50 $self->check_role_exclusions(@_);
51 $self->check_required_methods(@_);
709c321c 52 $self->check_required_attributes(@_);
d03bd989 53
1c9db35c 54 $self->apply_attributes(@_);
d03bd989 55 $self->apply_methods(@_);
56
1c9db35c 57 $self->apply_override_method_modifiers(@_);
d03bd989 58
1c9db35c 59 $self->apply_before_method_modifiers(@_);
60 $self->apply_around_method_modifiers(@_);
61 $self->apply_after_method_modifiers(@_);
fb1e11d5 62}
63
547dda77 64sub check_role_exclusions { Carp::croak "Abstract Method" }
65sub check_required_methods { Carp::croak "Abstract Method" }
66sub check_required_attributes { Carp::croak "Abstract Method" }
67
68sub apply_attributes { Carp::croak "Abstract Method" }
69sub apply_methods { Carp::croak "Abstract Method" }
70sub apply_override_method_modifiers { Carp::croak "Abstract Method" }
71sub apply_method_modifiers { Carp::croak "Abstract Method" }
bca01282 72
73sub apply_before_method_modifiers { (shift)->apply_method_modifiers('before' => @_) }
74sub apply_around_method_modifiers { (shift)->apply_method_modifiers('around' => @_) }
75sub apply_after_method_modifiers { (shift)->apply_method_modifiers('after' => @_) }
fb1e11d5 76
771;
78
79__END__
80
81=pod
82
83=head1 NAME
84
ab76842e 85Moose::Meta::Role::Application - A base class for role application
fb1e11d5 86
87=head1 DESCRIPTION
88
89This is the abstract base class for role applications.
90
a5583b3a 91The API for this class and its subclasses still needs some
92consideration, and is intentionally not yet documented.
93
fb1e11d5 94=head2 METHODS
95
96=over 4
97
98=item B<new>
99
100=item B<meta>
101
c4538447 102=item B<get_method_exclusions>
103
104=item B<is_method_excluded>
105
3e19778d 106=item B<get_method_aliases>
107
108=item B<is_aliased_method>
109
110=item B<is_method_aliased>
111
fb1e11d5 112=item B<apply>
113
709c321c 114=item B<check_role_exclusions>
115
fb1e11d5 116=item B<check_required_methods>
117
709c321c 118=item B<check_required_attributes>
fb1e11d5 119
120=item B<apply_attributes>
121
122=item B<apply_methods>
123
124=item B<apply_method_modifiers>
125
126=item B<apply_before_method_modifiers>
127
128=item B<apply_after_method_modifiers>
129
130=item B<apply_around_method_modifiers>
131
132=item B<apply_override_method_modifiers>
133
134=back
135
136=head1 BUGS
137
d4048ef3 138See L<Moose/BUGS> for details on reporting bugs.
fb1e11d5 139
140=head1 AUTHOR
141
142Stevan Little E<lt>stevan@iinteractive.comE<gt>
143
144=head1 COPYRIGHT AND LICENSE
145
7e0492d3 146Copyright 2006-2010 by Infinity Interactive, Inc.
fb1e11d5 147
148L<http://www.iinteractive.com>
149
150This library is free software; you can redistribute it and/or modify
151it under the same terms as Perl itself.
152
153=cut
154