/usr/share/perl5/MooseX/Declare/Context/Namespaced.pm is in libmoosex-declare-perl 0.43-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 | package MooseX::Declare::Context::Namespaced;
# ABSTRACT: Namespaced context
our $VERSION = '0.43';
use Moose::Role;
use Carp qw( croak );
use MooseX::Declare::Util qw( outer_stack_peek );
use namespace::autoclean;
#pod =head1 DESCRIPTION
#pod
#pod This context trait will add namespace functionality to the context.
#pod
#pod =attr namespace
#pod
#pod This will be set when the C<strip_namespace> method is called and the
#pod namespace wasn't anonymous. It will contain the specified namespace, not
#pod the fully qualified one.
#pod
#pod =cut
has namespace => (
is => 'rw',
isa => 'Str',
);
#pod =method strip_namespace
#pod
#pod Maybe[Str] Object->strip_namespace()
#pod
#pod This method is intended to parse the main namespace of a namespaced keyword.
#pod It will use L<Devel::Declare::Context::Simple>s C<strip_word> method and store
#pod the result in the L</namespace> attribute if true.
#pod
#pod =cut
sub strip_namespace {
my ($self) = @_;
my $namespace = $self->strip_word;
$self->namespace($namespace)
if defined $namespace and length $namespace;
return $namespace;
}
#pod =method qualify_namespace
#pod
#pod Str Object->qualify_namespace(Str $namespace)
#pod
#pod If the C<$namespace> passed it begins with a C<::>, it will be prefixed with
#pod the outer namespace in the file. If there is no outer namespace, an error
#pod will be thrown.
#pod
#pod =cut
sub qualify_namespace {
my ($self, $namespace) = @_;
# only qualify namespaces starting with ::
return $namespace
unless $namespace =~ /^::/;
# try to find the enclosing package
my $outer = outer_stack_peek($self->caller_file)
or croak "No outer namespace found to apply relative $namespace to";
return $outer . $namespace;
}
#pod =head1 SEE ALSO
#pod
#pod =for :list
#pod * L<MooseX::Declare>
#pod * L<MooseX::Declare::Context>
#pod
#pod =cut
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
MooseX::Declare::Context::Namespaced - Namespaced context
=head1 VERSION
version 0.43
=head1 DESCRIPTION
This context trait will add namespace functionality to the context.
=head1 ATTRIBUTES
=head2 namespace
This will be set when the C<strip_namespace> method is called and the
namespace wasn't anonymous. It will contain the specified namespace, not
the fully qualified one.
=head1 METHODS
=head2 strip_namespace
Maybe[Str] Object->strip_namespace()
This method is intended to parse the main namespace of a namespaced keyword.
It will use L<Devel::Declare::Context::Simple>s C<strip_word> method and store
the result in the L</namespace> attribute if true.
=head2 qualify_namespace
Str Object->qualify_namespace(Str $namespace)
If the C<$namespace> passed it begins with a C<::>, it will be prefixed with
the outer namespace in the file. If there is no outer namespace, an error
will be thrown.
=head1 SEE ALSO
=over 4
=item *
L<MooseX::Declare>
=item *
L<MooseX::Declare::Context>
=back
=head1 AUTHOR
Florian Ragwitz <rafl@debian.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2008 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
|