=head1 NAME

OpenFrame::WebApp::Segment::Template - abstract class for getting Templates
from the store.

=head1 SYNOPSIS

  # abstract class - cannot be used directly

  use base qw( OpenFrame::WebApp::Segment::Template );

  sub dispatch {
      ...
      my $template $self->get_template_from_store;
      ...
  }

=cut

package OpenFrame::WebApp::Segment::Template;

use strict;
use warnings::register;

use OpenFrame::WebApp::Template;
use OpenFrame::WebApp::Error::Abstract;

our $VERSION = (split(/ /, '$Revision: 1.2 $'))[1];

use base qw( Pipeline::Segment );

## try various methods to find a template in the store
sub get_template_from_store {
    my $self = shift;
    my $template;

    if ($self->store->isa( 'Pipeline::Store::ISA' )) {
	$template = $self->store->get('OpenFrame::WebApp::Template');
    } else {
	foreach my $class (values %{ OpenFrame::WebApp::Template->types }) {
	    last if( $template = $self->store->get($class) );
	}
    }

    return $template;
}

1;

__END__

=head1 DESCRIPTION

The C<OpenFrame::WebApp::Segment::Template> class provides a method for getting
Template objects from the store.

This class inherits its interface from C<Pipeline::Segment>.  You must override
dispatch() for it to do anything.

=head1 METHODS

=over 4

=item get_template_from_store

If the store is a C<Pipeline::Store::ISA>, looks for a descendant of
C<OpenFrame::WebApp::Template>, otherwise looks for known
OpenFrame::WebApp::Template->types().

=back

=head1 AUTHOR

Steve Purkis <spurkis@epn.nu>

=head1 COPYRIGHT

Copyright (c) 2003 Steve Purkis.  All rights reserved.
Released under the same license as Perl itself.

=head1 SEE ALSO

L<Pipeline::Segment>,
L<OpenFrame::WebApp::Template>

=cut
