Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / MooseX / Declare / Context / Parameterized.pm
1 package MooseX::Declare::Context::Parameterized;
2
3 use Moose::Role;
4 use MooseX::Types::Moose qw/Str HashRef/;
5
6 use namespace::autoclean;
7
8 has parameter_signature => (
9     is        => 'rw',
10     isa       => Str,
11     predicate => 'has_parameter_signature',
12 );
13
14 has parameters => (
15     traits    => ['Hash'],
16     isa       => HashRef,
17     default   => sub { {} },
18     handles   => {
19         add_parameter  => 'set',
20         get_parameters => 'kv',
21     },
22 );
23
24 sub 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
35 1;
36 __END__
37
38 =head1 NAME
39
40 MooseX::Declare::Context::Parameterized - context for parsing optionally parameterized statements
41
42 =head1 DESCRIPTION
43
44 This context trait will add optional parameterization functionality to the
45 context.
46
47 =head1 ATTRIBUTES
48
49 =head2 parameter_signature
50
51 This will be set when the C<strip_parameter_signature> method is called and it
52 was able to extract a list of parameterisations.
53
54 =head1 METHODS
55
56 =head2 has_parameter_signature
57
58 Predicate method for the C<parameter_signature> attribute.
59
60 =head2 strip_parameter_signature
61
62   Maybe[Str] Object->strip_parameter_signature()
63
64 This method is intended to parse the main namespace of a namespaced keyword.
65 It will use L<Devel::Declare::Context::Simple>s C<strip_word> method and store
66 the result in the L</namespace> attribute if true.
67
68 =head2 add_parameter
69
70 Allows storing parameters extracted from C<parameter_signature> to be used
71 later on.
72
73 =head2 get_parameters
74
75 Returns 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
89 See L<MooseX::Declare>
90
91 =cut