Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / MooseX / Declare / Util.pm
1 use strict;
2 use warnings;
3
4 package MooseX::Declare::Util;
5
6 use Sub::Exporter -setup => {
7     exports => [qw(
8         outer_stack_push
9         outer_stack_pop
10         outer_stack_peek
11     )],
12 };
13
14 my %OuterStack;
15
16 sub outer_stack_push {
17     my ($file, $value) = @_;
18
19     push @{ $OuterStack{ $file } }, $value;
20     return $value;
21 }
22
23 sub outer_stack_pop {
24     my ($file) = @_;
25
26     return undef
27         unless @{ $OuterStack{ $file } || [] };
28     return pop @{ $OuterStack{ $file } };
29 }
30
31 sub outer_stack_peek {
32     my ($file) = @_;
33
34     return undef
35         unless @{ $OuterStack{ $file } || [] };
36     return $OuterStack{ $file }[-1];
37 }
38
39 1;
40
41 =head1 NAME
42
43 MooseX::Declare::Util - Common declarative utility functions
44
45 =head1 DESCRIPTION
46
47 This exporter collection contains the commonly used functions in L<MooseX::Declare>.
48
49 =head1 EXPORTS
50
51 =head2 outer_stack_push
52
53   outer_stack_push (Str $file, Str $value)
54
55 Pushes the C<$value> on the internal stack for the file C<$file>.
56
57 =head2 outer_stack_pop
58
59   outer_stack_pop (Str $file)
60
61 Removes one item from the internal stack of the file C<$file>.
62
63 =head2 outer_stack_peek
64
65   outer_stack_peek (Str $file)
66
67 Returns the topmost item in the internal stack for C<$file> without removing
68 it from the stack.
69
70 =head1 SEE ALSO
71
72 =over
73
74 =item * L<MooseX::Declare>
75
76 =back
77
78 =head1 AUTHOR, COPYRIGHT & LICENSE
79
80 See L<MooseX::Declare>
81
82 =cut