/usr/share/perl5/MooseX/MethodAttributes/Role/Meta/Class.pm is in libmoosex-methodattributes-perl 0.29-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | package MooseX::MethodAttributes::Role::Meta::Class;
{
$MooseX::MethodAttributes::Role::Meta::Class::VERSION = '0.29';
}
BEGIN {
$MooseX::MethodAttributes::Role::Meta::Class::AUTHORITY = 'cpan:FLORA';
}
# ABSTRACT: metaclass role for storing code attributes
use Moose::Role;
use Moose::Util qw/find_meta does_role/;
use namespace::autoclean;
with qw/
MooseX::MethodAttributes::Role::Meta::Map
/;
sub get_method_with_attributes_list {
my ($self) = @_;
my @methods = map { $self->get_method($_) } $self->get_method_list;
my %order;
{
my $i = 0;
$order{$_} = $i++ for @{ $self->_method_attribute_list };
}
return map {
$_->[1]
} sort {
$order{ $a->[0] } <=> $order{ $b->[0] }
} map {
my $addr = 0 + $_->_get_attributed_coderef;
exists $self->_method_attribute_map->{$addr}
? [$addr, $_]
: ()
} grep {
$_->can('_get_attributed_coderef')
} @methods;
}
sub get_all_methods_with_attributes {
my ($self) = @_;
my %seen;
return reverse grep {
!$seen{ $_->name }++
} reverse map {
my $meth;
my $meta = find_meta($_);
($meta && ($meth = $meta->can('get_method_with_attributes_list')))
? $meta->$meth
: ()
} reverse $self->linearized_isa;
}
sub get_nearest_methods_with_attributes {
my ($self) = @_;
my @list = map {
my $m = $self->find_method_by_name($_->name);
my $meth = $m->can('attributes');
my $attrs = $meth ? $m->$meth() : [];
scalar @{ $attrs } ? ( $m ) : ( );
} $self->get_all_methods_with_attributes;
return @list;
}
foreach my $type (qw/after before around/) {
around "add_${type}_method_modifier" => sub {
my $orig = shift;
my $meta = shift;
my ($method_name) = @_;
my $code = $meta->$orig(@_);
my $method = $meta->get_method($method_name);
if (
does_role($method->get_original_method, 'MooseX::MethodAttributes::Role::Meta::Method')
|| does_role($method->get_original_method, 'MooseX::MethodAttributes::Role::Meta::Method::Wrapped')
) {
MooseX::MethodAttributes::Role::Meta::Method::Wrapped->meta->apply($method);
}
return $code;
}
}
1;
__END__
=pod
=encoding UTF-8
=for :stopwords Florian Ragwitz Tomas Doran
=head1 NAME
MooseX::MethodAttributes::Role::Meta::Class - metaclass role for storing code attributes
=head1 VERSION
version 0.29
=head1 METHODS
=head2 get_method_with_attributes_list
Gets the list of meta methods for local methods of this class that have
attributes in the order they have been registered.
=head2 get_all_methods_with_attributes
Gets the list of meta methods of local and inherited methods of this class,
that have attributes. Base class methods come before subclass methods. Methods
of one class have the order they have been declared in.
=head2 get_nearest_methods_with_attributes
The same as get_all_methods_with_attributes, except that methods from parent classes
are not included if there is an attribute-less method in a child class.
For example, given:
package BaseClass;
sub foo : Attr {}
sub bar : Attr {}
package SubClass;
use base qw/BaseClass/;
sub foo {}
after bar => sub {}
C<< SubClass->meta->get_all_methods_with_attributes >> will return
C<< BaseClass->meta->get_method('foo') >> for the above example, but
this method will not, and will return the wrapped bar method, whereas
C<< get_all_methods_with_attributes >> will return the original method.
=head1 AUTHORS
=over 4
=item *
Florian Ragwitz <rafl@debian.org>
=item *
Tomas Doran <bobtfish@bobtfish.net>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2009 by Florian Ragwitz.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|