lib/MojoMojo/Schema/ResultSet/Content.pm

filter: Statementstmt 44.8% 13 / 29 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 50.0% 20 / 40 CC 3 SCAR 10.0
CC
3
Cov
42%
create_proto
6.0
format_content
2.0
BEGIN
1.0
CRAP 2.7
« lib/MojoMojo/Formatter/IDLink.pm ↑ Summary lib/MojoMojo/Schema/Result/Attachment.pm »
1 package MojoMojo::Schema::ResultSet::Content;
2  
3 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use parent qw/MojoMojo::Schema::Base::ResultSet/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 MojoMojo::Schema::ResultSet::Content - resultset methods on content
10  
11 =head1 METHODS
12  
13 =head2 format_content
14  
15 $formatted_content = format_content($c, $content, $page);
16  
17 Call all available formatters to format content, according to their
18 format_content_order.
19  
20 =cut
21  
22 118 ▶sub format_content {
Subroutine format_content: called CC=2 SCAR=7.1
Pod documented
23  
24 # FIXME: This thing should use accept-context and stop fucking around with $c everywhere
25 118 my ( $self, $c, $content, $page ) = @_;
26 118 ▶ MojoMojo->call_plugins( "format_content", \$content, $c, $page )
Branch: 1 branch
BranchTrueFalseTotal
if $content 118 0 118
27 if ($content);
28 118 return $content;
29 }
30  
31 =head2 create_proto <page>
32  
33 Create a content prototype hash, as the basis for a new revision.
34  
35 =cut
36  
37 0 ▶sub create_proto {
Subroutine create_proto: not called CC=2 SCAR=17.9
Pod documented
38 0 my ( $class, $page ) = @_;
39 0 my %proto_content;
40 0 my @columns = $class->result_source->columns;
41 0 eval {
42 0 $page->isa('MojoMojo::Schema::Page');
43 0 $page->content->isa('MojoMojo::Schema::Content');
44 };
45 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
46  
47 # assume page is a simple "proto page" hashref,
48 # or the page has no content yet
49 0 %proto_content = map { $_ => undef } @columns;
50 0 $proto_content{version} = 1;
51 }
52 else {
53 0 my $content = $page->content;
54 0 %proto_content = map { $_ => $content->$_ } @columns;
55 0 @proto_content{qw/ creator created comments /} = (undef) x 3;
56 0 $proto_content{version}++;
57 }
58 0 return \%proto_content;
59 }
60  
61 =head1 AUTHOR
62  
63 Marcus Ramberg <mramberg@cpan.org>
64  
65 =head1 LICENSE
66  
67 This library is free software. You can redistribute it and/or modify
68 it under the same terms as Perl itself.
69  
70 =cut
71  
72 40 1;
« lib/MojoMojo/Formatter/IDLink.pm ↑ Summary lib/MojoMojo/Schema/Result/Attachment.pm »