line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Yeb::Class; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
59
|
$Yeb::Class::AUTHORITY = 'cpan:GETTY'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Meta Class for all Yeb application classes |
6
|
|
|
|
|
|
|
$Yeb::Class::VERSION = '0.103'; |
7
|
2
|
|
|
2
|
|
12
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
17
|
|
8
|
2
|
|
|
2
|
|
694
|
use Package::Stash; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
9
|
2
|
|
|
2
|
|
3200
|
use Class::Load ':all'; |
|
2
|
|
|
|
|
57672
|
|
|
2
|
|
|
|
|
408
|
|
10
|
2
|
|
|
2
|
|
1204
|
use Path::Tiny qw( path ); |
|
2
|
|
|
|
|
16403
|
|
|
2
|
|
|
|
|
2489
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has app => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has class => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has package_stash => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
lazy => 1, |
25
|
6
|
|
|
6
|
|
1198
|
builder => sub { Package::Stash->new(shift->class) }, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
sub add_function { |
28
|
182
|
|
|
182
|
0
|
1708
|
my ( $self, $func, $coderef ) = @_; |
29
|
182
|
|
|
|
|
4341
|
$self->package_stash->add_symbol('&'.$func,$coderef); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
3
|
|
443
|
has chain_links => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
lazy => 1, |
35
|
|
|
|
|
|
|
builder => sub {[]}, |
36
|
|
|
|
|
|
|
); |
37
|
21
|
|
|
21
|
0
|
323
|
sub chain { @{shift->chain_links} } |
|
21
|
|
|
|
|
505
|
|
38
|
10
|
|
|
10
|
0
|
18
|
sub add_to_chain { push @{shift->chain_links}, @_ } |
|
10
|
|
|
|
|
224
|
|
39
|
1
|
|
|
1
|
0
|
2
|
sub prepend_to_chain { unshift @{shift->chain_links}, @_ } |
|
1
|
|
|
|
|
4
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has yeb_class_functions => ( |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
lazy => 1, |
44
|
|
|
|
|
|
|
builder => sub { |
45
|
6
|
|
|
6
|
|
1187
|
my ( $self ) = @_; |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
0
|
|
0
|
plugin => sub { $self->app->add_plugin($self->class,@_) }, |
48
|
|
|
|
|
|
|
|
49
|
8
|
|
|
8
|
|
396
|
r => sub { $self->add_to_chain(@_); return; }, |
|
8
|
|
|
|
|
52
|
|
50
|
0
|
|
|
0
|
|
0
|
route => sub { $self->yeb_class_functions->{'r'}->(@_) }, |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
nop => sub (&) { |
53
|
0
|
|
|
0
|
|
0
|
my ( $code ) = @_; |
54
|
|
|
|
|
|
|
return sub { |
55
|
0
|
|
|
0
|
|
0
|
$code->(@_); |
56
|
0
|
|
|
|
|
0
|
return; |
57
|
0
|
|
|
|
|
0
|
}; |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
pr => sub { |
61
|
2
|
|
|
2
|
|
16
|
my $route = shift; |
62
|
2
|
|
|
|
|
3
|
my $post_route; |
63
|
2
|
100
|
|
|
|
7
|
if (ref $_[0] eq 'CODE') { |
64
|
1
|
|
|
|
|
3
|
$post_route = "POST"; |
65
|
|
|
|
|
|
|
} else { |
66
|
1
|
|
|
|
|
2
|
$post_route = "POST + ".(shift); |
67
|
|
|
|
|
|
|
} |
68
|
2
|
|
|
|
|
9
|
my $post_func = shift; |
69
|
2
|
|
|
|
|
4
|
my @args = @_; |
70
|
|
|
|
|
|
|
$self->add_to_chain($route, sub { |
71
|
|
|
|
|
|
|
return $post_route, sub { |
72
|
2
|
|
|
|
|
830
|
shift; $post_func->(@_); return; |
|
2
|
|
|
|
|
158
|
|
|
2
|
|
|
|
|
8
|
|
73
|
4
|
|
|
4
|
|
8111
|
}, @args; |
74
|
2
|
|
|
|
|
17
|
}); |
75
|
2
|
|
|
|
|
54
|
return; |
76
|
|
|
|
|
|
|
}, |
77
|
0
|
|
|
0
|
|
0
|
post_route => sub { $self->yeb_class_functions->{'pr'}->(@_) }, |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
middleware => sub { |
80
|
0
|
|
|
0
|
|
0
|
my $middleware = shift; |
81
|
0
|
|
|
0
|
|
0
|
$self->prepend_to_chain( "" => sub { $middleware } ); |
|
0
|
|
|
|
|
0
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
6
|
|
|
|
|
639
|
}, |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub call { |
88
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $func, @args ) = @_; |
89
|
0
|
0
|
|
|
|
0
|
return $self->yeb_class_functions->{$func}->(@_) if defined $self->yeb_class_functions->{$func}; |
90
|
0
|
|
|
|
|
0
|
return $self->app->call($func,@args); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub BUILD { |
94
|
6
|
|
|
6
|
0
|
4053
|
my ( $self ) = @_; |
95
|
|
|
|
|
|
|
|
96
|
6
|
|
|
|
|
14
|
for (keys %{$self->app->yeb_functions}) { |
|
6
|
|
|
|
|
134
|
|
97
|
132
|
|
|
|
|
19298
|
$self->add_function($_,$self->app->yeb_functions->{$_}); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
6
|
|
|
|
|
252
|
for (keys %{$self->yeb_class_functions}) { |
|
6
|
|
|
|
|
170
|
|
101
|
42
|
|
|
|
|
1360
|
$self->add_function($_,$self->yeb_class_functions->{$_}); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |