Changeset 55

Show
Ignore:
Timestamp:
02/08/06 19:50:45
Author:
miyagawa
Message:

update FeedType? to use Operator API

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Rule/FeedType.pm

    r53 r55  
    33use base qw( Plagger::Rule ); 
    44 
     5use Plagger::Operator; 
    56 
    67sub init { 
     
    910    if (my $type = $self->{type}) { 
    1011        $type = [ $type ] if ref($type) ne 'ARRAY'; 
    11         $self->{type} = +{ map {$_ => 1} @{ $type } }
     12        $self->{type} = $type
    1213    } else { 
    1314        Plagger->context->error("Can't parse type"); 
     15    } 
     16 
     17    $self->{op} ||= 'OR'; 
     18    unless (Plagger::Operator->is_valid_op($self->{op})) { 
     19        Plagger->context->error("Unsupported operator $self->{op}"); 
    1420    } 
    1521} 
     
    2329        or Plagger->context->error("No feed object in this plugin phase"); 
    2430 
    25     my $bool =  $self->{type}->{$feed->type}; 
    26     $bool = !$bool if $self->{negative}; 
    27     $bool; 
     31    my @bool; 
     32    for my $want (@{$self->{type}}) { 
     33        push @bool, ($feed->type eq $want); 
     34    } 
     35 
     36    Plagger::Operator->call($self->{op}, @bool); 
    2837} 
    2938