The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Contentment::Indexer - Interface for Index plugin indexers

SYNOPSIS

  package Contentment::MyPlugin::Indexer;

  # This isn't a requirement, but it's convenient if you only need one indexer
  use base qw( Class::Singleton );

  sub _new_instance {
      my $self = shift;
      $self->{indexes} = [ Contentment::MyPlugin::Index->instance ];
  }

  sub indexes {
      my $self = shift;

      return @{ $self->{indexes} };
  }

  sub for_generator {
      my $self      = shift;
      my $generator = shift;

      if ($generator->get_propery("my_plugin_likes_this_generator")) {
          return @{ $self->{indexes} };
      }

      else {
          return ();
      }
  }

  sub register {
      my $context = shift;
      $context->catalog->register_indexer(
          Contentment::MyPlugin::Indexer->instance
      );
  }

DESCRIPTION

An indexer plugin must provide two functions:

@indexes = $indexer->indexes

Returns a list of containing zero or more indexes. This should include all indexes and this method is used for searches or index listing. Each of these should implement the interface described in Contentment::Index.

Finally, your plugin will need to call the register_indexer() method (probably via the Contentment::Catalog::begin hook) of Contentment::Catalog so that the Index plugin knows how to find your indexer.

AUTHOR

Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>

LICENSE AND COPYRIGHT

Copyright 2005 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.