Terse/View.pm

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