[KinoSearch] Re: Subclassable Highlighter

Father Chrysostomos sprout at cpan.org
Fri Feb 29 12:36:59 PST 2008


On Feb 29, 2008, at 12:08 PM, Marvin Humphrey wrote:

> In either case, it's really no more work than providing your own  
> custom subclass of the present version of Encoder.  It would be a  
> slightly different story if SimpleHTMLEncoder took params, because  
> then you might be spared from having to subclass in some cases.  But  
> since all SimpleHTMLEncoder does is override encode(), there's no  
> advantage.

Actually, my main point was that the highlighter should accept a code  
ref (I didn’t stress it enough). I was trying to come up with a way to  
make that work (and I’m getting a little too used to the current  
system :-). Basically,

my $highlighter = new KinoSearch::Highlight::Highlighter ...;
$highlighter->set_encoder(sub { ... })

is a lot shorter (and less convoluted) than

{ package MyHighlighter;
   @ISA = KinoSearch::Highlight::Highlighter;
   sub encode { ... } }

my $highlighter = new MyHighlighter ...;





More information about the kinosearch mailing list