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