root/trunk/plagger/lib/Plagger/Subscription.pm

Revision 20 (checked in by miyagawa, 15 years ago)

updated subscription and aggregator.aggregate API so you can register custom feed type

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Subscription;
2 use strict;
3 use base qw( Plagger::Update );
4
5 sub new {
6     my $class = shift;
7     bless { feeds => [], by_tags => {}, by_types => {} }, $class;
8 }
9
10 sub add {
11     my($self, $feed) = @_;
12     push @{ $self->{feeds} }, $feed;
13     for my $tag ( @{$feed->tags} ) {
14         push @{ $self->{by_tags}->{$tag} }, $feed;
15     }
16     push @{ $self->{by_types}->{$feed->type} }, $feed;
17 }
18
19 sub types {
20     my $self = shift;
21     keys %{ $self->{by_types} };
22 }
23
24 sub feeds_by_type {
25     my($self, $type) = @_;
26     @{ $self->{by_types}->{$type} || [] };
27 }
28
29 1;
Note: See TracBrowser for help on using the browser.