Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / MooseX / Declare / Context / Parameterized.pm
CommitLineData
3fea05b9 1package MooseX::Declare::Context::Parameterized;
2
3use Moose::Role;
4use MooseX::Types::Moose qw/Str HashRef/;
5
6use namespace::autoclean;
7
8has parameter_signature => (
9 is => 'rw',
10 isa => Str,
11 predicate => 'has_parameter_signature',
12);
13
14has parameters => (
15 traits => ['Hash'],
16 isa => HashRef,
17 default => sub { {} },
18 handles => {
19 add_parameter => 'set',
20 get_parameters => 'kv',
21 },
22);
23
24sub strip_parameter_signature {
25 my ($self) = @_;
26
27 my $signature = $self->strip_proto;
28
29 $self->parameter_signature($signature)
30 if defined $signature && length $signature;
31
32 return $signature;
33}
34
351;
36__END__
37
38=head1 NAME
39
40MooseX::Declare::Context::Parameterized - context for parsing optionally parameterized statements
41
42=head1 DESCRIPTION
43
44This context trait will add optional parameterization functionality to the
45context.
46
47=head1 ATTRIBUTES
48
49=head2 parameter_signature
50
51This will be set when the C<strip_parameter_signature> method is called and it
52was able to extract a list of parameterisations.
53
54=head1 METHODS
55
56=head2 has_parameter_signature
57
58Predicate method for the C<parameter_signature> attribute.
59
60=head2 strip_parameter_signature
61
62 Maybe[Str] Object->strip_parameter_signature()
63
64This method is intended to parse the main namespace of a namespaced keyword.
65It will use L<Devel::Declare::Context::Simple>s C<strip_word> method and store
66the result in the L</namespace> attribute if true.
67
68=head2 add_parameter
69
70Allows storing parameters extracted from C<parameter_signature> to be used
71later on.
72
73=head2 get_parameters
74
75Returns all previously added parameters.
76
77=head1 SEE ALSO
78
79=over
80
81=item * L<MooseX::Declare>
82
83=item * L<MooseX::Declare::Context>
84
85=back
86
87=head1 AUTHOR, COPYRIGHT & LICENSE
88
89See L<MooseX::Declare>
90
91=cut