On Wed, 14 Jun 2006, J Cook wrote:
> <& 'some/comp.mas', foo => $foo, bar => "baz", %ARGS %>
> 
> What would I change it to, but more importantly in 'some/comp.mas':

% # in main mason component
% use My::Module;
% do_thing({ foo => $foo, bar => "baz", %ARGS });

...

package My::Module;
use Perl6::Export::Attrs;
use English '-no_match_vars';
use Carp qw( croak confess );

# personally I use my own Exception::Class hierarchy but top autohandler
# must correctly rethrow HTML::Mason::Exception::Abort exception objects
# for things like redirects in that case

sub do_thing :Export( :DEFAULT ) {
    my ($p) = @_;
    my $foo = $p->{foo};

    # being a code filter, Switch.pm sometimes screws up, so oh well
    return eval {
        if ($foo eq 'hork') {
            return _do_hork($p);
        }
        elsif ($foo eq 'zeeble') {
            return _do_zeeble($p);
        }
    };
    croak($EVAL_ERROR) if $EVAL_ERROR;
}

sub _do_hork {
    my ($p) = @_;
    my ($bar, $biz, $baz) = @{$p}{qw( bar biz baz )};
    return eval { # do stuff };
    confess($EVAL_ERROR) if $EVAL_ERROR;
}

sub _do_zeeble {
    my ($p) = @_;
    my ($bar, $biz, $baz) = @{$p}{qw( bar biz baz )};
    return eval { # do stuff };
    confess($EVAL_ERROR) if $EVAL_ERROR;
}

1;


_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to