« blib/lib/HTML/Widgets/NavMenu/ToJSON.pm
↑ Summary
blib/lib/HTML/Widgets/NavMenu/ToJSON/Data_Persistence/YAML.pm »
| 1 | package HTML::Widgets::NavMenu::ToJSON::Data_Persistence; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use warnings FATAL => 'all'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use parent 'HTML::Widgets::NavMenu::Object'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 3 | __PACKAGE__->mk_acc_ref( | |||||||||
| 10 | [ | ||||||||||
| 11 | qw( | ||||||||||
| 12 | _data | ||||||||||
| 13 | ), | ||||||||||
| 14 | ] | ||||||||||
| 15 | ); | ||||||||||
| 16 | |||||||||||
| 17 | =head1 NAME | ||||||||||
| 18 | |||||||||||
| 19 | HTML::Widgets::NavMenu::ToJSON::Data_Persistence - Data persistence base class. | ||||||||||
| 20 | |||||||||||
| 21 | =head1 VERSION | ||||||||||
| 22 | |||||||||||
| 23 | Version 0.0.3 | ||||||||||
| 24 | |||||||||||
| 25 | =cut | ||||||||||
| 26 | |||||||||||
| 27 | 3 | our $VERSION = '0.0.3'; | |||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | =head1 SYNOPSIS | ||||||||||
| 31 | |||||||||||
| 32 | See L<HTML::Widgets::NavMenu::ToJSON> . | ||||||||||
| 33 | |||||||||||
| 34 | use HTML::Widgets::NavMenu::ToJSON::Data_Persistence; | ||||||||||
| 35 | |||||||||||
| 36 | my $foo = HTML::Widgets::NavMenu::ToJSON::Data_Persistence->new(); | ||||||||||
| 37 | |||||||||||
| 38 | =head1 SUBROUTINES/METHODS | ||||||||||
| 39 | |||||||||||
| 40 | =head2 $self->get_id_for_url($url) | ||||||||||
| 41 | |||||||||||
| 42 | Returns the id (an integer) for the url fragment $url . If an ID does not | ||||||||||
| 43 | exist, a new ID will be assigned and the old one incremented. | ||||||||||
| 44 | |||||||||||
| 45 | =cut | ||||||||||
| 46 | |||||||||||
| 47 | sub _get_id_persistence | ||||||||||
| 48 | { | ||||||||||
| 49 | 9 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_get_id_persistence: called CC=1 SCAR=0.0
| |||||||||||
| 50 | |||||||||||
| 51 | 9 | return $self->_data->{id_persistence}; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | sub _calc_initial_data | ||||||||||
| 55 | { | ||||||||||
| 56 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_calc_initial_data: called CC=1 SCAR=0.0
| |||||||||||
| 57 | |||||||||||
| 58 | 1 | return { id_persistence => { paths_ids => { }, next_id => 1, }, }; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | sub get_id_for_url | ||||||||||
| 62 | { | ||||||||||
| 63 | 9 | ▶ | my ($self, $url) = @_; | ||||||||
|
Subroutine
get_id_for_url: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 64 | |||||||||||
| 65 | 9 | my $ptr = $self->_get_id_persistence; | |||||||||
| 66 | |||||||||||
| 67 | 9 | ▶ | if (! exists($ptr->{paths_ids}->{$url})) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | { | ||||||||||
| 69 | 9 | $ptr->{paths_ids}->{$url} = ($ptr->{next_id}++); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 9 | return $ptr->{paths_ids}->{$url}; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | =head1 AUTHOR | ||||||||||
| 76 | |||||||||||
| 77 | Shlomi Fish, C<< <shlomif at cpan.org> >> | ||||||||||
| 78 | |||||||||||
| 79 | =head1 BUGS | ||||||||||
| 80 | |||||||||||
| 81 | Please report any bugs or feature requests to C<bug-html-widgets-navmenu-tojson at rt.cpan.org>, or through | ||||||||||
| 82 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-Widgets-NavMenu-ToJSON>. I will be notified, and then you'll | ||||||||||
| 83 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | |||||||||||
| 87 | |||||||||||
| 88 | =head1 SUPPORT | ||||||||||
| 89 | |||||||||||
| 90 | You can find documentation for this module with the perldoc command. | ||||||||||
| 91 | |||||||||||
| 92 | perldoc HTML::Widgets::NavMenu::ToJSON::Data_Persistence | ||||||||||
| 93 | |||||||||||
| 94 | |||||||||||
| 95 | You can also look for information at: | ||||||||||
| 96 | |||||||||||
| 97 | =over 4 | ||||||||||
| 98 | |||||||||||
| 99 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||
| 100 | |||||||||||
| 101 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-Widgets-NavMenu-ToJSON> | ||||||||||
| 102 | |||||||||||
| 103 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 104 | |||||||||||
| 105 | L<http://annocpan.org/dist/HTML-Widgets-NavMenu-ToJSON> | ||||||||||
| 106 | |||||||||||
| 107 | =item * CPAN Ratings | ||||||||||
| 108 | |||||||||||
| 109 | L<http://cpanratings.perl.org/d/HTML-Widgets-NavMenu-ToJSON> | ||||||||||
| 110 | |||||||||||
| 111 | =item * Search CPAN | ||||||||||
| 112 | |||||||||||
| 113 | L<http://search.cpan.org/dist/HTML-Widgets-NavMenu-ToJSON/> | ||||||||||
| 114 | |||||||||||
| 115 | =back | ||||||||||
| 116 | |||||||||||
| 117 | |||||||||||
| 118 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 119 | |||||||||||
| 120 | |||||||||||
| 121 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 122 | |||||||||||
| 123 | Copyright 2012 Shlomi Fish. | ||||||||||
| 124 | |||||||||||
| 125 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 126 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||
| 127 | copy of the full license at: | ||||||||||
| 128 | |||||||||||
| 129 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||
| 130 | |||||||||||
| 131 | Any use, modification, and distribution of the Standard or Modified | ||||||||||
| 132 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||
| 133 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||
| 134 | or distribute the Package, if you do not accept this license. | ||||||||||
| 135 | |||||||||||
| 136 | If your Modified Version has been derived from a Modified Version made | ||||||||||
| 137 | by someone other than you, you are nevertheless required to ensure that | ||||||||||
| 138 | your Modified Version complies with the requirements of this license. | ||||||||||
| 139 | |||||||||||
| 140 | This license does not grant you the right to use any trademark, service | ||||||||||
| 141 | mark, tradename, or logo of the Copyright Holder. | ||||||||||
| 142 | |||||||||||
| 143 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||
| 144 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||
| 145 | otherwise transfer the Package with respect to any patent claims | ||||||||||
| 146 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||
| 147 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||
| 148 | counterclaim) against any party alleging that the Package constitutes | ||||||||||
| 149 | direct or contributory patent infringement, then this Artistic License | ||||||||||
| 150 | to you shall terminate on the date that such litigation is filed. | ||||||||||
| 151 | |||||||||||
| 152 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||
| 153 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||
| 154 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||
| 155 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||
| 156 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||
| 157 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||
| 158 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||
| 159 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||
| 160 | |||||||||||
| 161 | |||||||||||
| 162 | =cut | ||||||||||
| 163 | |||||||||||
| 164 | 3 | 1; # End of HTML::Widgets::NavMenu::ToJSON::Data_Persistence | |||||||||