my $entry = shift;
my $ns = XML::Atom::Namespace->new(dc => 'http://purl.org/dc/elements/1.1/');
if (@_) {
- $entry->{entry}->add_category({ term => $_[0] });
+ $entry->{entry}->add_category({ term => $_ }) for @_;
+ return 1
} else {
- my $category = $entry->{entry}->category;
- my @return = $category ? ($category->label || $category->term) : $entry->{entry}->getlist($ns, 'subject');
+
+
+ my @category = ($entry->{entry}->can('categories')) ? $entry->{entry}->categories : $entry->{entry}->category;
+ my @return = @category
+ ? (map { $_->label || $_->term } @category)
+ : $entry->{entry}->getlist($ns, 'subject');
+
return wantarray? @return : $return[0];
}
}