/usr/share/perl5/Catalyst/ClassData.pm is in libcatalyst-perl 5.90103-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 | package Catalyst::ClassData;
use Moose::Role;
use Moose::Meta::Class ();
use Class::MOP;
use Moose::Util ();
sub mk_classdata {
my ($class, $attribute, $warn_on_instance) = @_;
confess("mk_classdata() is a class method, not an object method")
if blessed $class;
my $slot = '$'.$attribute;
my $accessor = sub {
my $pkg = ref $_[0] || $_[0];
my $meta = Moose::Util::find_meta($pkg)
|| Moose::Meta::Class->initialize( $pkg );
if (@_ > 1) {
$meta->namespace->{$attribute} = \$_[1];
return $_[1];
}
# tighter version of
# if ( $meta->has_package_symbol($slot) ) {
# return ${ $meta->get_package_symbol($slot) };
# }
no strict 'refs';
my $v = *{"${pkg}::${attribute}"}{SCALAR};
if (defined ${$v}) {
return ${$v};
} else {
foreach my $super ( $meta->linearized_isa ) {
# tighter version of same after
# my $super_meta = Moose::Meta::Class->initialize($super);
my $v = ${"${super}::"}{$attribute} ? *{"${super}::${attribute}"}{SCALAR} : undef;
if (defined ${$v}) {
return ${$v};
}
}
}
return;
};
confess("Failed to create accessor: $@ ")
unless ref $accessor eq 'CODE';
my $meta = $class->Class::MOP::Object::meta();
confess "${class}'s metaclass is not a Class::MOP::Class"
unless $meta->isa('Class::MOP::Class');
my $was_immutable = $meta->is_immutable;
my %immutable_options = $meta->immutable_options;
$meta->make_mutable if $was_immutable;
my $alias = "_${attribute}_accessor";
$meta->add_method($alias, $accessor);
$meta->add_method($attribute, $accessor);
$meta->make_immutable(%immutable_options) if $was_immutable;
$class->$attribute($_[2]) if(@_ > 2);
return $accessor;
}
1;
__END__
=head1 NAME
Catalyst::ClassData - Class data accessors
=head1 METHODS
=head2 mk_classdata $name, $optional_value
A moose-safe clone of L<Class::Data::Inheritable> that borrows some ideas from
L<Class::Accessor::Grouped>;
=head1 AUTHOR
=begin stopwords
Guillermo Roditi
=end stopwords
=head1 COPYRIGHT
This library is free software. You can redistribute it and/or modify it under
the same terms as Perl itself.
=cut
|