| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::AutoCRUD::Controller::Schema; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
543
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
33
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
26
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
|
|
extends 'App::AutoCRUD::Controller'; |
|
9
|
1
|
|
|
1
|
|
4665
|
use YAML; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
68
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use Clone qw/clone/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use namespace::clean -except => 'meta'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
16
|
|
|
|
|
|
|
# entry point to the controller |
|
17
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
18
|
|
|
|
|
|
|
sub serve { |
|
19
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# extract from path : method to dispatch to |
|
22
|
1
|
50
|
|
|
|
27
|
my $meth_name = $self->context->extract_path_segments(1) |
|
23
|
|
|
|
|
|
|
or die "URL too short, missing method name"; |
|
24
|
1
|
50
|
|
|
|
6
|
my $method = $self->can($meth_name) |
|
25
|
|
|
|
|
|
|
or die "no such method: $meth_name"; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# dispatch to method |
|
28
|
1
|
|
|
|
|
4
|
return $self->$method(); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
32
|
|
|
|
|
|
|
# published methods |
|
33
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub tablegroups { |
|
36
|
1
|
|
|
1
|
1
|
1
|
my ($self) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
24
|
my $context = $self->context; |
|
39
|
1
|
|
|
|
|
26
|
$context->set_template("schema/tablegroups.tt"); |
|
40
|
1
|
|
|
|
|
24
|
return $context->datasource->tablegroups; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub perl_code { |
|
44
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# set view to "plain" |
|
47
|
0
|
0
|
|
|
|
|
my $view_class = $self->app->find_class("View::Plain") |
|
48
|
|
|
|
|
|
|
or die "no Plain view"; |
|
49
|
0
|
|
|
|
|
|
$self->context->set_view($view_class->new); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# call datasource schema (which may indirectly generate the perl class |
|
52
|
|
|
|
|
|
|
# on the fly, from the DBI connection) |
|
53
|
0
|
|
|
|
|
|
my $schema = $self->datasource->schema; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# retrieve perl code, either just generated, or from an existing .pm module |
|
56
|
0
|
|
0
|
|
|
|
my $perl_code = $self->datasource->generated_schema || do { |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# retrieve loaded classname |
|
59
|
|
|
|
|
|
|
my $schema_class = $self->datasource->loaded_class || ref $schema || $schema; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# find source file and slurp its content |
|
62
|
|
|
|
|
|
|
$schema_class =~ s[::][/]g; |
|
63
|
|
|
|
|
|
|
my $path = $INC{$schema_class . ".pm"} |
|
64
|
|
|
|
|
|
|
or die "can't find source code for $schema_class.pm"; |
|
65
|
|
|
|
|
|
|
open my $fh, "<", $path |
|
66
|
|
|
|
|
|
|
or die "can't open $path"; |
|
67
|
|
|
|
|
|
|
local $/; |
|
68
|
|
|
|
|
|
|
<$fh>; |
|
69
|
|
|
|
|
|
|
}; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $perl_code; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 NAME |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
App::AutoCRUD::Controller::Schema |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This controller serves information from a given |
|
86
|
|
|
|
|
|
|
L<App::AutoCRUD::DataSource> instance. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 METHODS |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 tablegroups |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns the content of |
|
93
|
|
|
|
|
|
|
L<App::AutoCRUD::DataSource/tablegroups>. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 perl_code |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Returns source code of the L<DBIx::DataModel> schema |
|
98
|
|
|
|
|
|
|
associated with the datasource (this can be either |
|
99
|
|
|
|
|
|
|
an existing Perl class, loaded from the config, or |
|
100
|
|
|
|
|
|
|
some Perl code generated on the fly from the L<DBI> |
|
101
|
|
|
|
|
|
|
connection). |