Class/Role/PostResultSet.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran n/a Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 38 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Perlanet::DBIx::Class::Role::PostResultSet;
2 # ABSTRACT: Role for the ResultSet which contains a list of saved posts
3  
4 use strict;
5 use warnings FATAL => 'all';
6  
7 use Moose::Role;
8 use Method::Signatures::Simple;
9 use namespace::autoclean;
10  
11 method create_from_perlanet ($post)
12 {
13 $self->create($self->munge_from_perlanet($post));
14 }
15  
16 method munge_from_perlanet ($post)
17 {
18 return {
19 feed_id => $post->feed->id,
20 author => $post->_entry->author || $post->feed->title,
21 url => $post->_entry->link,
22 title => $post->_entry->title,
23 posted_on => $post->_entry->issued || DateTime->now,
24 summary => $post->_entry->summary->body ||
25 $post->_entry->content->body,
26 body => $post->_entry->content->body,
27 }
28 }
29  
30 method has_post ($post)
31 {
32 return $self->search( { url => $post->link } )->count > 0;
33 }
34  
35 1;
36  
37 __END__