line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Model::CacheFunky::Loader; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
397987
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
100
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
84
|
|
5
|
3
|
|
|
3
|
|
17
|
use base qw/Catalyst::Model/; |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
2412
|
|
6
|
3
|
|
|
3
|
|
1900394
|
use NEXT; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
71
|
|
7
|
3
|
|
|
3
|
|
3113
|
use Module::Recursive::Require; |
|
3
|
|
|
|
|
17372
|
|
|
3
|
|
|
|
|
46
|
|
8
|
3
|
|
|
3
|
|
105
|
use Carp; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
573
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
1
|
27919
|
my $self = shift->NEXT::new(@_); |
14
|
1
|
|
|
|
|
2099
|
my $c = shift; |
15
|
1
|
|
|
|
|
4
|
my $class = ref($self); |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
3
|
my $funky_class = $self->{class}; |
18
|
1
|
|
|
|
|
3
|
my $funky_config = $self->{initialize_info}; |
19
|
1
|
|
50
|
|
|
9
|
my $mrr_args = $self->{mrr_args} || {}; |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
33
|
|
|
11
|
croak 'You must set class and initialize_info' |
22
|
|
|
|
|
|
|
unless $funky_class && $funky_config; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
13
|
my @funkies = Module::Recursive::Require->new($mrr_args) |
25
|
|
|
|
|
|
|
->require_by($funky_class); |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
|
20
|
no strict 'refs'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
639
|
|
28
|
1
|
|
|
|
|
3970
|
for my $funky (@funkies) { |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
6
|
$funky->setup( %{$funky_config} ); |
|
2
|
|
|
|
|
30
|
|
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
8048
|
my $funky_short = $funky; |
33
|
2
|
|
|
|
|
25
|
$funky_short =~ s/^$funky_class\:\://g; |
34
|
2
|
|
|
|
|
7
|
my $classname = "${class}::$funky_short"; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
1
|
|
10
|
*{"${funky}::context"} = sub {$c}; |
|
2
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
30
|
|
37
|
2
|
|
|
|
|
21
|
*{"${classname}::ACCEPT_CONTEXT"} = sub { |
38
|
5
|
|
|
5
|
|
1386400
|
return $funky; |
39
|
2
|
|
|
|
|
9
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
10
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Catalyst::Model::CacheFunky::Loader - Load Cache::Funky Modules. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
package MyApp::Model::Funky; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
use strict; |
56
|
|
|
|
|
|
|
use warnings; |
57
|
|
|
|
|
|
|
use base qw/Catalyst::Model::CacheFunky::Loader/; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__PACKAGE__->config( |
60
|
|
|
|
|
|
|
class => 'MyApp::CacheFunky', # read all module under MyApp::CacheFunky::* |
61
|
|
|
|
|
|
|
initialize_info => { 'Storage::Simple' => {} }, |
62
|
|
|
|
|
|
|
mrr_args => { path => '/var/www/Common/lib/' } , # option. SEE L<Module::Recursive::Require> new(\%args) |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
package MyApp::CacheFunky::Foo; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use strict; |
70
|
|
|
|
|
|
|
use warnings; |
71
|
|
|
|
|
|
|
use qw/Cache::Funky/; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__PACKAGE__->register( 'foo', sub {`date`} ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
package MyAPpCacheFunky::Users; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use strict; |
80
|
|
|
|
|
|
|
use warnings; |
81
|
|
|
|
|
|
|
use qw/Cache::Funky/; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__PACKAGE__->register( 'user_count', |
84
|
|
|
|
|
|
|
sub { __PACKAGE__->context()->model('DB::Users')->count(); } ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
package MyApp::Controller::FooBar; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub foo : Local { |
91
|
|
|
|
|
|
|
my ( $s, $c ) = @_; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$c->log->debug( $c->model('Funky::Foo')->foo() ); |
94
|
|
|
|
|
|
|
sleep(1); |
95
|
|
|
|
|
|
|
$c->log->debug( $c->model('Funky::Foo')->foo() ); |
96
|
|
|
|
|
|
|
sleep(1); |
97
|
|
|
|
|
|
|
$c->model('Funky::Foo')->delete('foo'); |
98
|
|
|
|
|
|
|
$c->log->debug( $c->model('Funky::Foo')->foo() ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
[ %c . forward( 'Model::Funky::Foo', 'foo' ) % ] |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Load L<Cache::Funky> modules and make them ready for you. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 METHOD |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 new |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SEE ALSO |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<Module::Recursive::Require> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Tomohiro Teranishi <tomohiro.teranishi@gmail.com> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Copyright (c) Tomohiro Teranishi, All rights reserved. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L<perlartistic>. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|