line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Sugar; |
2
|
2
|
|
|
2
|
|
21498
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
84
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
859
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
2
|
|
|
|
|
9934
|
|
|
2
|
|
|
|
|
15
|
|
6
|
2
|
|
|
2
|
|
1417
|
use Scalar::Util qw(reftype); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
200
|
|
7
|
2
|
|
|
2
|
|
1801
|
use Data::Types qw(is_string); |
|
2
|
|
|
|
|
3203
|
|
|
2
|
|
|
|
|
707
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Some sweet stuff for Mojolicious |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub register { |
14
|
1
|
|
|
1
|
1
|
54
|
my ( $self, $app ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$app->helper( |
17
|
|
|
|
|
|
|
'flash_add_to' => sub { |
18
|
3
|
|
|
3
|
|
32648
|
my $c = shift; |
19
|
3
|
|
|
|
|
12
|
my $session = $c->session; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Initialize new flash and merge values |
22
|
3
|
|
100
|
|
|
48
|
my $flash = $session->{new_flash} ||= {}; |
23
|
|
|
|
|
|
|
|
24
|
3
|
50
|
33
|
|
|
15
|
if ( @_ > 1 && is_string($_[0]) ) { |
25
|
3
|
|
|
|
|
195
|
my $key = shift; |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
5
|
my $current_value = $flash->{$key}; |
28
|
|
|
|
|
|
|
|
29
|
3
|
50
|
66
|
|
|
22
|
if ( defined $current_value && reftype($current_value) ne 'ARRAY' ) { |
30
|
0
|
|
|
|
|
0
|
$current_value = [ $current_value ]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
7
|
foreach my $value (@_) { |
34
|
4
|
|
|
|
|
3
|
push @{ $current_value }, $value; |
|
4
|
|
|
|
|
14
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
13
|
$flash->{$key} = $current_value; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
1
|
|
|
|
|
16
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$app->helper( |
43
|
|
|
|
|
|
|
'params' => sub { |
44
|
1
|
|
|
1
|
|
40701
|
return shift->req->params; |
45
|
|
|
|
|
|
|
} |
46
|
1
|
|
|
|
|
117
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |