1 package Moose::Meta::Role::Application;
8 $VERSION = eval $VERSION;
9 our $AUTHORITY = 'cpan:STEVAN';
11 __PACKAGE__->meta->add_attribute('method_exclusions' => (
12 init_arg => '-excludes',
13 reader => 'get_method_exclusions',
17 __PACKAGE__->meta->add_attribute('method_aliases' => (
19 reader => 'get_method_aliases',
24 my ($class, %params) = @_;
26 if (exists $params{excludes} && !exists $params{'-excludes'}) {
27 $params{'-excludes'} = delete $params{excludes};
29 if (exists $params{alias} && !exists $params{'-alias'}) {
30 $params{'-alias'} = delete $params{alias};
33 if (exists $params{'-excludes'}) {
34 # I wish we had coercion here :)
35 $params{'-excludes'} = (ref $params{'-excludes'} eq 'ARRAY'
36 ? $params{'-excludes'}
37 : [ $params{'-excludes'} ]);
40 $class->_new(\%params);
43 sub is_method_excluded {
44 my ($self, $method_name) = @_;
45 foreach (@{$self->get_method_exclusions}) {
46 return 1 if $_ eq $method_name;
51 sub is_method_aliased {
52 my ($self, $method_name) = @_;
53 exists $self->get_method_aliases->{$method_name} ? 1 : 0
56 sub 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;
65 $self->check_role_exclusions(@_);
66 $self->check_required_methods(@_);
67 $self->check_required_attributes(@_);
69 $self->apply_attributes(@_);
70 $self->apply_methods(@_);
72 $self->apply_override_method_modifiers(@_);
74 $self->apply_before_method_modifiers(@_);
75 $self->apply_around_method_modifiers(@_);
76 $self->apply_after_method_modifiers(@_);
79 sub check_role_exclusions { Carp::croak "Abstract Method" }
80 sub check_required_methods { Carp::croak "Abstract Method" }
81 sub check_required_attributes { Carp::croak "Abstract Method" }
83 sub apply_attributes { Carp::croak "Abstract Method" }
84 sub apply_methods { Carp::croak "Abstract Method" }
85 sub apply_override_method_modifiers { Carp::croak "Abstract Method" }
86 sub apply_method_modifiers { Carp::croak "Abstract Method" }
88 sub apply_before_method_modifiers { (shift)->apply_method_modifiers('before' => @_) }
89 sub apply_around_method_modifiers { (shift)->apply_method_modifiers('around' => @_) }
90 sub apply_after_method_modifiers { (shift)->apply_method_modifiers('after' => @_) }
100 Moose::Meta::Role::Application - A base class for role application
104 This is the abstract base class for role applications.
106 The API for this class and its subclasses still needs some
107 consideration, and is intentionally not yet documented.
117 =item B<get_method_exclusions>
119 =item B<is_method_excluded>
121 =item B<get_method_aliases>
123 =item B<is_aliased_method>
125 =item B<is_method_aliased>
129 =item B<check_role_exclusions>
131 =item B<check_required_methods>
133 =item B<check_required_attributes>
135 =item B<apply_attributes>
137 =item B<apply_methods>
139 =item B<apply_method_modifiers>
141 =item B<apply_before_method_modifiers>
143 =item B<apply_after_method_modifiers>
145 =item B<apply_around_method_modifiers>
147 =item B<apply_override_method_modifiers>
153 All complex software has bugs lurking in it, and this module is no
154 exception. If you find a bug please either email me, or add the bug
159 Stevan Little E<lt>stevan@iinteractive.comE<gt>
161 =head1 COPYRIGHT AND LICENSE
163 Copyright 2006-2009 by Infinity Interactive, Inc.
165 L<http://www.iinteractive.com>
167 This library is free software; you can redistribute it and/or modify
168 it under the same terms as Perl itself.