Model/JSON/ViewData.pm

filter: Statementstmt 71.4% 10 / 14 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod n/a totaltotal 65.0% 13 / 20 CC 2 SCAR 11.0
CC
2
Cov
62%
AUTOLOAD
6.0
BEGIN
1.0
build_per_context_instance
1.0
CRAP 3.0
« View/JSON/_PerRequest.pm ↑ Summary View/JSON/PerRequest.pm »
1 package Catalyst::Model::JSON::ViewData;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 1 extends 'Catalyst::Model';
6 1 with 'Catalyst::Component::InstancePerContext';
7 1 with 'Data::Perl::Role::Collection::Hash';
8
9 4 ▶sub build_per_context_instance {
Subroutine build_per_context_instance: called CC=1 SCAR=0.0
10 4 my ($self, $c, %args) = @_;
11 4 return $self->new(%args);
12 }
13
14 4 ▶sub TO_JSON { +{shift->elements} }
Subroutine TO_JSON: called CC=1 SCAR=0.0
15
16 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
17 0 my ($self, @args) = @_;
18 0 my $key = our $AUTOLOAD;
19 0 $key =~ s/.*:://;
20 0 ▶ return scalar(@args) ?
Branch: 1 branch
BranchTrueFalseTotal
scalar @args ? : 0 0 0
21 $self->set($key, @args)
22 : $self->get($key);
23 }
24
25 1 1;
26  
27 =head1 NAME
28  
29 Catalyst::Model::JSON::ViewData - Default model for Catalyst::View::JSON::PerRequest
30  
31 =head1 SYNOPSIS
32  
33 sub root :Chained(/) CaptureArgs(0) {
34 my ($self, $c) = @_;
35 $c->view->data->set(z=>1);
36 }
37  
38 =head1 DESCRIPTION
39  
40 This is the default model used by L<Catalyst::View::JSON::PerRequest> to
41 collect information that will be presented as JSON data to the client.
42  
43 Generally you will access this via '$c->view->data'. However it is setup as a
44 per request model in Catalyst so you can access it via '$c->model("JSON::ViewData")'.
45 which might have some use if you are populating values in other dependent models.
46  
47 =head1 METHODS
48  
49 This model consumes the role L<Data::Perl::Role::Collection::Hash> and gets
50 all its method from it.
51  
52 =head1 SEE ALSO
53  
54 L<Catalyst::View::JSON::PerRequest>, L<Catalyst>, L<Data::Perl>, L<Moo>.
55  
56 =head1 AUTHOR
57
58 John Napiorkowski L<email:jjnapiork@cpan.org>
59
60 =head1 COPYRIGHT & LICENSE
61
62 Copyright 2015, John Napiorkowski L<email:jjnapiork@cpan.org>
63
64 This library is free software; you can redistribute it and/or modify it under
65 the same terms as Perl itself.
66  
67 =cut
« View/JSON/_PerRequest.pm ↑ Summary View/JSON/PerRequest.pm »