File Coverage

blib/lib/Statocles/Link/Tree.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Statocles::Link::Tree;
2             our $VERSION = '0.086';
3             # ABSTRACT: A link object with child links, making a tree
4              
5             #pod =head1 SYNOPSIS
6             #pod
7             #pod my $link = Statocles::Link::Tree->new(
8             #pod href => '/',
9             #pod text => 'Home',
10             #pod children => [
11             #pod {
12             #pod href => '/blog',
13             #pod text => 'Blog',
14             #pod },
15             #pod {
16             #pod href => '/projects',
17             #pod text => 'Projects',
18             #pod },
19             #pod ],
20             #pod );
21             #pod
22             #pod =head1 DESCRIPTION
23             #pod
24             #pod This class represents a link which is allowed to have child links.
25             #pod This allows making trees of links for multi-level menus.
26             #pod
27             #pod =head1 SEE ALSO
28             #pod
29             #pod L<Statocles::Link>
30             #pod
31             #pod =cut
32              
33 68     68   445 use Statocles::Base 'Class';
  68         138  
  68         556  
34             extends 'Statocles::Link';
35              
36             #pod =attr children
37             #pod
38             #pod $link->children([
39             #pod # Object
40             #pod Statocles::Link::Tree->new(
41             #pod href => '/blog',
42             #pod text => 'Blog',
43             #pod ),
44             #pod
45             #pod # Hashref of attributes
46             #pod {
47             #pod href => '/about',
48             #pod text => 'About',
49             #pod },
50             #pod
51             #pod # URL only
52             #pod 'http://example.com',
53             #pod ]);
54             #pod
55             #pod The children of this link. Should be an arrayref of
56             #pod C<Statocles::Link::Tree> objects, hashrefs of attributes for
57             #pod C<Statocles::Link::Tree> objects, or URLs which will be used as the
58             #pod C<href> attribute for a C<Statocles::Link::Tree> object.
59             #pod
60             #pod =cut
61              
62             has children => (
63             is => 'rw',
64             isa => LinkTreeArray,
65             coerce => LinkTreeArray->coercion,
66             default => sub { [] },
67             );
68              
69             1;
70              
71             __END__
72              
73             =pod
74              
75             =encoding UTF-8
76              
77             =head1 NAME
78              
79             Statocles::Link::Tree - A link object with child links, making a tree
80              
81             =head1 VERSION
82              
83             version 0.086
84              
85             =head1 SYNOPSIS
86              
87             my $link = Statocles::Link::Tree->new(
88             href => '/',
89             text => 'Home',
90             children => [
91             {
92             href => '/blog',
93             text => 'Blog',
94             },
95             {
96             href => '/projects',
97             text => 'Projects',
98             },
99             ],
100             );
101              
102             =head1 DESCRIPTION
103              
104             This class represents a link which is allowed to have child links.
105             This allows making trees of links for multi-level menus.
106              
107             =head1 ATTRIBUTES
108              
109             =head2 children
110              
111             $link->children([
112             # Object
113             Statocles::Link::Tree->new(
114             href => '/blog',
115             text => 'Blog',
116             ),
117              
118             # Hashref of attributes
119             {
120             href => '/about',
121             text => 'About',
122             },
123              
124             # URL only
125             'http://example.com',
126             ]);
127              
128             The children of this link. Should be an arrayref of
129             C<Statocles::Link::Tree> objects, hashrefs of attributes for
130             C<Statocles::Link::Tree> objects, or URLs which will be used as the
131             C<href> attribute for a C<Statocles::Link::Tree> object.
132              
133             =head1 SEE ALSO
134              
135             L<Statocles::Link>
136              
137             =head1 AUTHOR
138              
139             Doug Bell <preaction@cpan.org>
140              
141             =head1 COPYRIGHT AND LICENSE
142              
143             This software is copyright (c) 2016 by Doug Bell.
144              
145             This is free software; you can redistribute it and/or modify it under
146             the same terms as the Perl 5 programming language system itself.
147              
148             =cut