On 09/24/2007 11:02 AM, Peter Karman wrote:
> 
> On 09/23/2007 11:28 AM, Marcus Ramberg wrote:
>> Catalyst::Model::Search is a quite old module which have been living
>> in Catalyst trunk for quite a while. It's being used by MojoMojo, and
>> it just happened to work, so I pushed it to CPAN so that MojoMojo
>> could depend on it. If anyone want to clean it up or document the
>> Search base class, patches are more than welcome.
>>
> 
> See attached.
> 

oops. Forgot to include the 'required' boilerplate.

new version attached.
-- 
Peter Karman  .  [EMAIL PROTECTED]  .  http://peknet.com/

--- Search.pm.orig	2007-09-24 10:33:51.534326000 -0500
+++ Search.pm	2007-09-24 11:16:11.646096000 -0500
@@ -4,69 +4,157 @@
 use NEXT;
 use base qw/Catalyst::Base/;
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
-sub new { 
+sub new {
     my ( $self, $c ) = @_;
-
-    return $self->NEXT::new( $c );
+    $self->init($c);
+    return $self->NEXT::new($c);
 }
 
 sub init {
     my $self = shift;
-    
+    my $c    = shift;
+
     Catalyst::Exception->throw(
-        message => ( ref $self || $self ) . ' does not implement init()'
-    );
+        message => ( ref $self || $self ) . ' does not implement init()' );
 }
 
 sub add {
     my $self = shift;
-    
+    my $data = shift;
+
     Catalyst::Exception->throw(
-        message => ( ref $self || $self ) . ' does not implement add()'
-    );
+        message => ( ref $self || $self ) . ' does not implement add()' );
 }
 
 sub update {
     my $self = shift;
-    
+    my $data = shift;
+
     Catalyst::Exception->throw(
-        message => ( ref $self || $self ) . ' does not implement update()'
-    );
+        message => ( ref $self || $self ) . ' does not implement update()' );
 }
 
 sub remove {
     my $self = shift;
-    
+    my $data = shift;
+
     Catalyst::Exception->throw(
-        message => ( ref $self || $self ) . ' does not implement remove()'
-    );
+        message => ( ref $self || $self ) . ' does not implement remove()' );
 }
 
 sub query {
-    my $self = shift;
-    
+    my $self  = shift;
+    my $query = shift;
+
     Catalyst::Exception->throw(
-        message => ( ref $self || $self ) . ' does not implement query()'
-    );
+        message => ( ref $self || $self ) . ' does not implement query()' );
 }
 
 sub is_indexed {
     my $self = shift;
-    
-    Catalyst::Exception->throw(
-        message => ( ref $self || $self ) . ' does not implement is_indexed()'
-    );
+    my $key  = shift;
+
+    Catalyst::Exception->throw( message => ( ref $self || $self )
+            . ' does not implement is_indexed()' );
 }
 
 sub optimize {
     my $self = shift;
-    
-    Catalyst::Exception->throw(
-        message => ( ref $self || $self ) . ' does not implement optimize()'
-    );
+
+    Catalyst::Exception->throw( message => ( ref $self || $self )
+            . ' does not implement optimize()' );
 }
 
 1;
 __END__
+
+
+=head1 NAME
+
+Catalyst::Model::Search - base class for Catalyst search models
+
+=head1 SYNOPSIS
+
+ package Catalyst::Model::MySearchApp;
+ use base qw(Catalyst::Model::Search);
+ 
+ # must implement all the following methods
+ sub init       {}
+ sub add        {}
+ sub update     {}
+ sub remove     {}
+ sub query      {}
+ sub is_indexed {}
+ sub optimize   {}
+ 
+=head1 DESCRIPTION
+
+Catalyst::Model::Search is a base class for providing full-text search
+to a Catalyst application. The premise is that existing search projects
+can be integrated with Catalyst's Model framework using a common API, allowing
+you to swap in Xapian or KinoSearch or Plucene or Swish-e or 
+I<YourSearchAppHere> without needing to change any Controller or View code.
+
+=head1 METHODS
+
+The following methods are implemented. Those methods 
+that must be overridden in your subclass are marked as such.
+
+=head2 new
+
+The basic boilerplate new() required by Catalyst::Model subclasses.
+The init() method is called by new().
+
+=head2 init
+
+Setup your search indexes or any other initialization required.
+B<This method must be overridden.>
+
+=head2 add( I<data> )
+
+Add I<data> to an index.
+B<This method must be overridden.>
+
+=head2 update( I<data> )
+
+Update I<data> in an index.
+B<This method must be overridden.>
+
+=head2 remove( I<data> )
+
+Remove I<data> from an index.
+B<This method must be overridden.>
+
+=head2 query ( I<query> )
+
+Search an index for I<query>. In scalar context should return
+a Catalyst::Model::Search::Results object. In array context should
+return the value of a Results object's get_items() method.
+B<This method must be overridden.>
+
+=head2 is_indexed( I<key> )
+
+Test the index for the presence of a record identified by I<key>
+Returns true if the record is in the index.
+B<This method must be overridden.>
+
+=head2 optimize
+
+Perform optimizing magic on the index.
+B<This method must be overridden.>
+
+=head1 AUTHOR
+
+Andy Grundman, <[EMAIL PROTECTED]>
+Marcus Ramberg, <[EMAIL PROTECTED]>
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
+ 
_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to