Terse/View.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 50.0% 1 / 2 totaltotal 73.6% 14 / 19 CC 2 SCAR 5.6
CC
2
Cov
79%
new
2.0
render
2.0
BEGIN
1.0
CRAP 1.8
« Terse/Plugin.pm ↑ Summary Terse/Model.pm »
1 package Terse::View;
2  
3 1 ▶use base 'Terse';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 sub new {
6 1 ▶ my ($pkg, @args) = @_;
Subroutine new: called CC=2 SCAR=7.0
Pod documented
7 1 my $self = $pkg->SUPER::new(@args);
8 1 my ($namespace) = $pkg =~ m/([^:]+)$/;
9 1 $self->namespace = lc( $namespace );
10 1 ▶ $self->build_view() if ($self->can('build_view'));
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("build_view") 0 1 1
11 1 return $self;
12 }
13  
14 sub render {
15 0 ▶ my ($self, $t, $data) = @_;
Subroutine render: not called CC=1 SCAR=6.9
Pod undocumented
16 0 return ('application/json', $data->pretty(1)->serialize())
17 }
18  
19 1 1;
20  
21 =head1 NAME
22  
23 Terse::View - views made simple.
24  
25 =head1 VERSION
26  
27 Version 0.123
28  
29 =cut
30  
31 =head1 SYNOPSIS
32  
33 package My::App::View::Pretty;
34  
35 use base 'Terse::View';
36  
37 1;
38  
39 ... If using Terse::App
40  
41 package My::App;
42  
43 use base 'Terse::App';
44  
45 sub build_app {
46 $_[0]->response_view = 'pretty'; # default all requests to use this view.
47 }
48  
49 sub auth {
50 shift;
51 $_[0]->controller('admin/auth')->authenticate(@_);
52 }
53  
54 ... else
55  
56 package MyApp;
57  
58 use base 'Terse::Controller';
59
60 use MyAppView;
61  
62 sub build_controller {
63 $_[0]->views->pretty = MyAppView->new();
64 $_[0]->response_view = 'pretty';
65 }
66  
67 sub overview :get {
68 $_[1]->response->data = $_[1]->model('data')->do_something();
69 }
70  
71  
72 =cut
73  
74 =head1 AUTHOR
75  
76 LNATION, C<< <email at lnation.org> >>
77  
78 =head1 LICENSE AND COPYRIGHT
79  
80 L<Terse>.
81  
82 =cut
83  
« Terse/Plugin.pm ↑ Summary Terse/Model.pm »