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