MasonX::Resolver::Multiplex - multiplex several Resolver objects


MasonX-Resolver-Multiplex documentation Contained in the MasonX-Resolver-Multiplex distribution.

Index


Code Index:

NAME

Top

MasonX::Resolver::Multiplex - multiplex several Resolver objects

VERSION

Top

Version 0.001

SYNOPSIS

Top

  use MasonX::Resolver::Multiplex;

  my $resolver = MasonX::Resolver::Multiplex->new(
    resolvers => [
      My::Custom::Resolver->new,
      HTML::Mason::Resolver::File->new,
    ],
  );

  my $interp = HTML::Mason::Interp->new(
    resolver => $resolver,
    # ... other options
  )

DESCRIPTION

Top

Use this Resolver subclass when you want to combine the behavior of other Resolver subclasses, such as in the SYNOPSIS.

This class delegates methods to its contained resolvers. Each method is called on each resolver in order; the first to return a true value 'wins'.

Delegated methods:

* get_info
* glob_path
* apache_request_to_comp_path (if present)

SEE ALSO

Top

HTML::Mason HTML::Mason::Resolver

AUTHOR

Top

Hans Dieter Pearcey, <hdp at pobox.com>

BUGS

Top

Please report any bugs or feature requests to bug-masonx-resolver-multiplex at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MasonX-Resolver-Multiplex. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc MasonX::Resolver::Multiplex




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=MasonX-Resolver-Multiplex

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/MasonX-Resolver-Multiplex

* CPAN Ratings

http://cpanratings.perl.org/d/MasonX-Resolver-Multiplex

* Search CPAN

http://search.cpan.org/dist/MasonX-Resolver-Multiplex

COPYRIGHT & LICENSE

Top


MasonX-Resolver-Multiplex documentation Contained in the MasonX-Resolver-Multiplex distribution.

use strict;
use warnings;

package MasonX::Resolver::Multiplex;

our $VERSION = '0.001';

use Moose;
BEGIN { extends 'HTML::Mason::Resolver' }

# play nicely with Class::Container
sub validation_spec {
  my ($self) = @_;
  return {
    %{ $self->SUPER::validation_spec || {} },
    resolvers => 1,
  },
}

has resolvers => (
  is => 'rw',
  isa => 'ArrayRef[HTML::Mason::Resolver]',
  lazy => 1,
  auto_deref => 1,
  default => sub { [] },
);

sub get_info {
  my $self = shift;
  my @args = @_;
  for my $res ($self->resolvers) {
    my $src = $res->get_info(@args);
    return $src if $src;
  }
  return;
}

sub glob_path {
  my $self = shift;
  my @args = @_;
  for my $res ($self->resolvers) {
    my @paths = $res->glob_path(@args);
    return @paths if @paths;
  }
  return;
}

sub apache_request_to_comp_path {
  my $self = shift;
  my @args = @_;
  for my $res ($self->resolvers) {
    next unless $res->can('apache_request_to_comp_path');
    my $path = $res->apache_request_to_comp_path(@args);
    return $path if $path;
  }
  return;
}

1;
__END__