blib/lib/Dancer/Plugin/Scoped.pm

filter: Statementstmt 65.2% 15 / 23 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 1 / 1 totaltotal 62.5% 20 / 32 CC 2 SCAR 5.6
CC
2
Cov
60%
__ANON__
3.4
scoped
1.5
BEGIN
1.0
CRAP 1.7
↑ Summary
1 package Dancer::Plugin::Scoped;
2 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 @EXPORT = qw( scoped );
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.02';
8  
9 0 ▶sub scoped (&) {
Subroutine scoped: not called CC=1 SCAR=3.8
Pod documented
10 0 my ($code) = @_;
11 0 my $caller = caller;
12 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=12.2
13 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 0 ▶ while (my ($k, $v) = each %{Dancer::SharedData->request->params}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{"Dancer::SharedData"->request->params;}) 0 0 0
15 0 ${"$caller\::$k"} = $v;
16 }
17 0 $code->(@_);
18 0 };
19 }
20  
21 =head1 NAME
22  
23 Dancer::Plugin::Scoped - Allows to set params variables in scope of route handler
24  
25 =head1 VERSION
26  
27 Version 0.02
28  
29 =cut
30  
31 =head1 SYNOPSIS
32  
33 use Dancer;
34 use Dancer::Plugin::Scoped;
35  
36 any '/' => scoped {
37 our ($page, $test);
38 template $page, { test => $test };
39 };
40  
41 $page, $test - these variables will be set according to params data, e.g. $page is a syntactic
42 alias to params->{page}.
43  
44 =head1 EXPORT
45  
46 scoped
47  
48 =head1 SUBROUTINES/METHODS
49  
50 =head2 scoped
51  
52 A replacement for sub in route handler definition. It sets variables passed in params hash which
53 is accessible via our declarations.
54  
55 =cut
56  
57 =head1 AUTHOR
58  
59 Roman Galeev, C<< <jamhedd at gmail.com> >>
60  
61 =head1 BUGS
62  
63 Please report any bugs or feature requests to C<bug-dancer-plugin-scoped at rt.cpan.org>, or through
64 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-Scoped>. I will be notified, and then you'll
65 automatically be notified of progress on your bug as I make changes.
66  
67 =head1 SUPPORT
68  
69 You can find documentation for this module with the perldoc command.
70  
71 perldoc Dancer::Plugin::Scoped
72  
73 You can also look for information at:
74  
75 =over 4
76  
77 =item * RT: CPAN's request tracker
78  
79 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-Scoped>
80  
81 =item * AnnoCPAN: Annotated CPAN documentation
82  
83 L<http://annocpan.org/dist/Dancer-Plugin-Scoped>
84  
85 =item * CPAN Ratings
86  
87 L<http://cpanratings.perl.org/d/Dancer-Plugin-Scoped>
88  
89 =item * Search CPAN
90  
91 L<http://search.cpan.org/dist/Dancer-Plugin-Scoped/>
92  
93 =back
94  
95 =head1 ACKNOWLEDGEMENTS
96  
97 =head1 LICENSE AND COPYRIGHT
98  
99 Copyright 2010 Roman Galeev.
100  
101 This program is free software; you can redistribute it and/or modify it
102 under the terms of either: the GNU General Public License as published
103 by the Free Software Foundation; or the Artistic License.
104  
105 See http://dev.perl.org/licenses/ for more information.
106  
107 =cut
108  
109 2 1; # End of Dancer::Plugin::Scoped
↑ Summary