1 package Moose::Meta::Role::Application;
8 our $AUTHORITY = 'cpan:STEVAN';
10 __PACKAGE__->meta->add_attribute('method_exclusions' => (
11 init_arg => 'excludes',
12 reader => 'get_method_exclusions',
16 __PACKAGE__->meta->add_attribute('method_aliases' => (
18 reader => 'get_method_aliases',
23 my ($class, %params) = @_;
25 if (exists $params{excludes}) {
26 # I wish we had coercion here :)
27 $params{excludes} = (ref $params{excludes} eq 'ARRAY'
29 : [ $params{excludes} ]);
32 $class->meta->new_object(%params);
35 sub is_method_excluded {
36 my ($self, $method_name) = @_;
37 foreach (@{$self->get_method_exclusions}) {
38 return 1 if $_ eq $method_name;
43 sub is_method_aliased {
44 my ($self, $method_name) = @_;
45 exists $self->get_method_aliases->{$method_name} ? 1 : 0
48 sub is_aliased_method {
49 my ($self, $method_name) = @_;
50 my %aliased_names = reverse %{$self->get_method_aliases};
51 exists $aliased_names{$method_name} ? 1 : 0;
57 $self->check_role_exclusions(@_);
58 $self->check_required_methods(@_);
59 $self->check_required_attributes(@_);
61 $self->apply_attributes(@_);
62 $self->apply_methods(@_);
64 $self->apply_override_method_modifiers(@_);
66 $self->apply_before_method_modifiers(@_);
67 $self->apply_around_method_modifiers(@_);
68 $self->apply_after_method_modifiers(@_);
71 sub check_role_exclusions { Carp::croak "Abstract Method" }
72 sub check_required_methods { Carp::croak "Abstract Method" }
73 sub check_required_attributes { Carp::croak "Abstract Method" }
75 sub apply_attributes { Carp::croak "Abstract Method" }
76 sub apply_methods { Carp::croak "Abstract Method" }
77 sub apply_override_method_modifiers { Carp::croak "Abstract Method" }
78 sub apply_method_modifiers { Carp::croak "Abstract Method" }
80 sub apply_before_method_modifiers { (shift)->apply_method_modifiers('before' => @_) }
81 sub apply_around_method_modifiers { (shift)->apply_method_modifiers('around' => @_) }
82 sub apply_after_method_modifiers { (shift)->apply_method_modifiers('after' => @_) }
92 Moose::Meta::Role::Application - A base class for role application
96 This is the abstract base class for role applications.
106 =item B<get_method_exclusions>
108 =item B<is_method_excluded>
110 =item B<get_method_aliases>
112 =item B<is_aliased_method>
114 =item B<is_method_aliased>
118 =item B<check_role_exclusions>
120 =item B<check_required_methods>
122 =item B<check_required_attributes>
124 =item B<apply_attributes>
126 =item B<apply_methods>
128 =item B<apply_method_modifiers>
130 =item B<apply_before_method_modifiers>
132 =item B<apply_after_method_modifiers>
134 =item B<apply_around_method_modifiers>
136 =item B<apply_override_method_modifiers>
142 All complex software has bugs lurking in it, and this module is no
143 exception. If you find a bug please either email me, or add the bug
148 Stevan Little E<lt>stevan@iinteractive.comE<gt>
150 =head1 COPYRIGHT AND LICENSE
152 Copyright 2006-2008 by Infinity Interactive, Inc.
154 L<http://www.iinteractive.com>
156 This library is free software; you can redistribute it and/or modify
157 it under the same terms as Perl itself.