JSORB::Dispatcher::Traits::WithContext - A dispatcher trait for context arguments


JSORB documentation Contained in the JSORB distribution.

Index


Code Index:

NAME

Top

JSORB::Dispatcher::Traits::WithContext - A dispatcher trait for context arguments

DESCRIPTION

Top

This is a dispatcher trait that expects a context object (i.e. - the Catalyst $c object) as the first argument.

BUGS

Top

All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.

AUTHOR

Top

Stevan Little <stevan.little@iinteractive.com>

COPYRIGHT AND LICENSE

Top


JSORB documentation Contained in the JSORB distribution.

package JSORB::Dispatcher::Traits::WithContext;
use Moose::Role;

our $VERSION   = '0.04';
our $AUTHORITY = 'cpan:STEVAN';

has 'context_class' => (
    is        => 'rw',
    isa       => 'Str',   
    predicate => 'has_context_class'
);

around 'assemble_params_list' => sub {
    my $next = shift;
    my ($self, $call, $context, @args) = @_;
    (blessed $context && $context->isa($self->context_class))
        || confess "Expected a context of type (" . $self->context_class . ") but got ($context)"
            if $self->has_context_class;    
    return ($context, $self->$next( $call, @args ));    
};

no Moose::Role; 1;

__END__