line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Model::JSON::ViewData; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
806
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Catalyst::Model'; |
6
|
|
|
|
|
|
|
with 'Catalyst::Component::InstancePerContext'; |
7
|
|
|
|
|
|
|
with 'Data::Perl::Role::Collection::Hash'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub build_per_context_instance { |
10
|
2
|
|
|
2
|
|
280
|
my ($self, $c, %args) = @_; |
11
|
2
|
|
|
|
|
53
|
return $self->new(%args); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
14
|
sub TO_JSON { +{shift->elements} } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub AUTOLOAD { |
17
|
6
|
|
|
6
|
|
15
|
my ($self, @args) = @_; |
18
|
6
|
|
|
|
|
11
|
my $key = our $AUTOLOAD; |
19
|
6
|
|
|
|
|
29
|
$key =~ s/.*:://; |
20
|
6
|
50
|
|
|
|
38
|
return scalar(@args) ? |
21
|
|
|
|
|
|
|
$self->set($key, @args) |
22
|
|
|
|
|
|
|
: $self->get($key); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
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 |