MooseX::Declare::Context::Parameterized - context for parsing optionally parameterized statements


MooseX-Declare documentation Contained in the MooseX-Declare distribution.

Index


Code Index:

NAME

Top

MooseX::Declare::Context::Parameterized - context for parsing optionally parameterized statements

DESCRIPTION

Top

This context trait will add optional parameterization functionality to the context.

ATTRIBUTES

Top

parameter_signature

This will be set when the strip_parameter_signature method is called and it was able to extract a list of parameterisations.

METHODS

Top

has_parameter_signature

Predicate method for the parameter_signature attribute.

add_parameter

Allows storing parameters extracted from parameter_signature to be used later on.

get_parameters

Returns all previously added parameters.

strip_parameter_signature

  Maybe[Str] Object->strip_parameter_signature()

This method is intended to parse the main namespace of a namespaced keyword. It will use Devel::Declare::Context::Simples strip_word method and store the result in the namespace attribute if true.

SEE ALSO

Top

AUTHORS

Top

COPYRIGHT AND LICENSE

Top


MooseX-Declare documentation Contained in the MooseX-Declare distribution.

package MooseX::Declare::Context::Parameterized;
BEGIN {
  $MooseX::Declare::Context::Parameterized::AUTHORITY = 'cpan:FLORA';
}
BEGIN {
  $MooseX::Declare::Context::Parameterized::VERSION = '0.34';
}
# ABSTRACT: context for parsing optionally parameterized statements

use Moose::Role;
use MooseX::Types::Moose qw/Str HashRef/;

use namespace::autoclean;


has parameter_signature => (
    is        => 'rw',
    isa       => Str,
    predicate => 'has_parameter_signature',
);


has parameters => (
    traits    => ['Hash'],
    isa       => HashRef,
    default   => sub { {} },
    handles   => {
        add_parameter  => 'set',
        get_parameters => 'kv',
    },
);


sub strip_parameter_signature {
    my ($self) = @_;

    my $signature = $self->strip_proto;

    $self->parameter_signature($signature)
        if defined $signature && length $signature;

    return $signature;
}


1;

__END__