Commit | Line | Data |
fb1e11d5 |
1 | package Moose::Meta::Role::Application; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use metaclass; |
6 | |
245478d5 |
7 | our $VERSION = '1.19'; |
75b95414 |
8 | $VERSION = eval $VERSION; |
fb1e11d5 |
9 | our $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 |
23 | sub new { |
c4538447 |
24 | my ($class, %params) = @_; |
1b8d1399 |
25 | $class->_new(\%params); |
c4538447 |
26 | } |
27 | |
28 | sub 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 |
36 | sub is_method_aliased { |
37 | my ($self, $method_name) = @_; |
38 | exists $self->get_method_aliases->{$method_name} ? 1 : 0 |
39 | } |
40 | |
41 | sub 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 |
47 | sub 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 |
64 | sub check_role_exclusions { Carp::croak "Abstract Method" } |
65 | sub check_required_methods { Carp::croak "Abstract Method" } |
66 | sub check_required_attributes { Carp::croak "Abstract Method" } |
67 | |
68 | sub apply_attributes { Carp::croak "Abstract Method" } |
69 | sub apply_methods { Carp::croak "Abstract Method" } |
70 | sub apply_override_method_modifiers { Carp::croak "Abstract Method" } |
71 | sub apply_method_modifiers { Carp::croak "Abstract Method" } |
bca01282 |
72 | |
73 | sub apply_before_method_modifiers { (shift)->apply_method_modifiers('before' => @_) } |
74 | sub apply_around_method_modifiers { (shift)->apply_method_modifiers('around' => @_) } |
75 | sub apply_after_method_modifiers { (shift)->apply_method_modifiers('after' => @_) } |
fb1e11d5 |
76 | |
77 | 1; |
78 | |
79 | __END__ |
80 | |
81 | =pod |
82 | |
83 | =head1 NAME |
84 | |
ab76842e |
85 | Moose::Meta::Role::Application - A base class for role application |
fb1e11d5 |
86 | |
87 | =head1 DESCRIPTION |
88 | |
89 | This is the abstract base class for role applications. |
90 | |
a5583b3a |
91 | The API for this class and its subclasses still needs some |
92 | consideration, 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 |
138 | See L<Moose/BUGS> for details on reporting bugs. |
fb1e11d5 |
139 | |
140 | =head1 AUTHOR |
141 | |
142 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
143 | |
144 | =head1 COPYRIGHT AND LICENSE |
145 | |
7e0492d3 |
146 | Copyright 2006-2010 by Infinity Interactive, Inc. |
fb1e11d5 |
147 | |
148 | L<http://www.iinteractive.com> |
149 | |
150 | This library is free software; you can redistribute it and/or modify |
151 | it under the same terms as Perl itself. |
152 | |
153 | =cut |
154 | |