package URI::NamespaceMap::ReservedLocalParts; use Moo 1.006000; use Types::Standard qw/ArrayRef Str/; use List::Util qw/first/; has allowed => ( is => 'ro', isa => ArrayRef [Str], default => sub { [qw/allowed disallowed is_reserved/] } ); has disallowed => (is => 'ro', isa => ArrayRef [Str], default => sub { [] }); sub is_reserved { my ($self, $keyword) = @_; return 0 if first { $_ eq $keyword } @{$self->allowed}; return 1 if first { $_ eq $keyword } @{$self->disallowed}; return $self->can($keyword) ? 1 : 0; } =head1 NAME URI::NamespaceMap::ReservedLocalParts - Permissible local parts for NamespaceMap =head1 VERSION Version 1.10 =cut our $VERSION = '1.10'; =head1 SYNOPSIS my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); say $r->is_reserved('isa'); # 1 say $r->is_reserved('uri'); # 1 say $r->is_reserved('foo'); # 0 =head1 DESCRIPTION L is an accompanying distribution to L. It's goal is to check for forbidden names used for local parts. Rather than creating a blacklist that needs to be maintained, it instantiates a new L object, and calls C on the invocant. Using this technique, it means that every method on every Perl object (C), and Moo objects (C) will be automatically black listed. =head1 ATTRIBUTES L implements the following attributes. =head2 allowed A whitelist of local part names. Defaults to C, C and C so that when C is called on the instance, it doesn't return a false positive for other method names associated with this package. =head2 disallowed A blacklist of local part names. Does not have a default set, but usually defaults to C when called from L. =head1 METHODS L implements the following methods. =head2 is_reserved my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); say $r->is_reserved('isa'); # 1 say $r->is_reserved('uri'); # 1 say $r->is_reserved('foo'); # 0 Checks if the first argument passed is reserved or not. Returns a C. =head1 FURTHER DETAILS See L for further details about authors, license, etc. =cut 1;