| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dancer::OO::Dancer; |
|
2
|
1
|
|
|
1
|
|
23316
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
63
|
|
|
3
|
1
|
|
|
1
|
|
25831
|
use Dancer (); |
|
|
1
|
|
|
|
|
462554
|
|
|
|
1
|
|
|
|
|
19
|
|
|
4
|
1
|
|
|
1
|
|
347
|
use YAML; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @route_handler = qw( get post any patch del options put ); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub debug { |
|
11
|
|
|
|
|
|
|
Dancer::debug( join( ' ', map { ref $_ ? Dump($_) : $_ } map { $_ ? $_ : '_' } @_ ) ); |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
|
15
|
|
|
|
|
|
|
my ($self) = @_; |
|
16
|
|
|
|
|
|
|
my $class = caller; |
|
17
|
|
|
|
|
|
|
no strict 'refs'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# redefine router handlers |
|
20
|
|
|
|
|
|
|
foreach my $handler (@route_handler) { |
|
21
|
|
|
|
|
|
|
*{"$class\::$handler"} = sub { |
|
22
|
|
|
|
|
|
|
push @{ ${"$class\::_handler"} }, [ $handler, @_ ]; |
|
23
|
|
|
|
|
|
|
}; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# dancer improvements |
|
27
|
|
|
|
|
|
|
*{"$class\::template"} = sub { |
|
28
|
|
|
|
|
|
|
my ( $self, $template, $args ) = @_; |
|
29
|
|
|
|
|
|
|
$args = {} unless $args; |
|
30
|
|
|
|
|
|
|
$args->{uri} = sub { join( '', ${"$self\::_prefix"}, $_[0] ) }; |
|
31
|
|
|
|
|
|
|
my $k = join( '/', ${"$self\::_prefix"}, 'pager' ); |
|
32
|
|
|
|
|
|
|
$args->{c} ||= Dancer::session($k) || {}; |
|
33
|
|
|
|
|
|
|
return Dancer::template( join( '/', ${"$self\::_prefix"}, $template ), $args ); |
|
34
|
|
|
|
|
|
|
}; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
*{"$class\::wrap"} = sub (&) { |
|
37
|
|
|
|
|
|
|
my ($handler) = @_; |
|
38
|
|
|
|
|
|
|
return sub { |
|
39
|
|
|
|
|
|
|
my ($self) = @_; |
|
40
|
|
|
|
|
|
|
return sub { |
|
41
|
|
|
|
|
|
|
my $params = Dancer::params; |
|
42
|
|
|
|
|
|
|
my $context = Dancer::session; |
|
43
|
|
|
|
|
|
|
my $ret = $handler->( $self, $context, $params ); |
|
44
|
|
|
|
|
|
|
Dancer::session( $context ); |
|
45
|
|
|
|
|
|
|
return $ret; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
}; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
*{"$class\::debug"} = \&debug; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# suck in all Dancer methods |
|
53
|
|
|
|
|
|
|
for my $method (@Dancer::EXPORT) { |
|
54
|
|
|
|
|
|
|
*{"$class\::$method"} = *{"Dancer\::$method"} if not defined &{"$class\::$method"}; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Dancer::OO::Dancer - Allows to set params variables in scope of route handler |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Version 0.01 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
use Dancer::OO::Dancer; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 EXPORT |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
All Dancer methods |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 debug |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
A replacement for default Dancer debug with automatic objects dumping with YAML::Dump method. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Roman Galeev, C<< >> |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 BUGS |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
91
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
92
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SUPPORT |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
perldoc Dancer::OO::Dancer |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
You can also look for information at: |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * Search CPAN |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Copyright 2012 Roman Galeev. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
129
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
130
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; # End of Dancer::OO::Dancer |