| 1 | package Feed::Data::Parser::Atom; | ||
| 2 | |||
| 3 | use Moo; | ||
| 4 | extends 'Feed::Data::Parser::Base'; | ||
| 5 | use XML::Atom::Feed; | ||
| 6 | use Compiled::Params::OO qw/cpo/; | ||
| 7 | use Types::Standard qw/Object Str/; | ||
| 8 | |||
| 9 | our $validate; | ||
| 10 | BEGIN { | ||
| 11 | $validate = cpo( | ||
| 12 | get_value => [Object, Object, Str], | ||
| 13 | ); | ||
| 14 | } | ||
| 15 | |||
| 16 | has '+parser' => ( | ||
| 17 | default => sub { | ||
| 18 | my $self = shift; | ||
| 19 | return XML::Atom::Feed->new($self->content_ref); | ||
| 20 | } | ||
| 21 | ); | ||
| 22 | |||
| 23 | sub get_value { | ||
| 24 | my ($self, $item, $action) = $validate->get_value->(@_); | ||
| 25 | |||
| 26 | return $item->$action ? $item->$action : ''; | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; # End of Feed::Data |