/usr/share/perl5/MooseX/Declare/Context/WithOptions.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 | package # hide from PAUSE
MooseX::Declare::Context::WithOptions;
our $VERSION = '0.43';
use Moose::Role;
use Carp qw/croak/;
use MooseX::Types::Moose 0.20 qw/HashRef/;
use namespace::autoclean;
has options => (
is => 'rw',
isa => HashRef,
default => sub { {} },
lazy => 1,
);
sub strip_options {
my ($self) = @_;
my %ret;
# Make errors get reported from right place in source file
local $Carp::Internal{'MooseX::Declare'} = 1;
local $Carp::Internal{'Devel::Declare'} = 1;
$self->skipspace;
my $linestr = $self->get_linestr;
while (substr($linestr, $self->offset, 1) !~ /[{;]/) {
my $key = $self->strip_name;
if (!defined $key) {
croak 'expected option name'
if keys %ret;
return; # This is the case when { class => 'foo' } happens
}
croak "unknown option name '$key'"
unless $key =~ /^(extends|with|is)$/;
my $val = $self->strip_name;
if (!defined $val) {
if (defined($val = $self->strip_proto)) {
$val = [split /\s*,\s*/, $val];
}
else {
croak "expected option value after $key";
}
}
$ret{$key} ||= [];
push @{ $ret{$key} }, ref $val ? @{ $val } : $val;
} continue {
$self->skipspace;
$linestr = $self->get_linestr();
}
my $options = { map {
my $key = $_;
$key eq 'is'
? ($key => { map { ($_ => 1) } @{ $ret{$key} } })
: ($key => $ret{$key})
} keys %ret };
$self->options($options);
return $options;
}
1;
|