Template::Plugin::Catalyst::View::PDF::Reuse::Barcode - Template::Plugin::Catalyst::View::PDF::Reuse::Barcode documentation


Catalyst-View-PDF-Reuse documentation Contained in the Catalyst-View-PDF-Reuse distribution.

Index


Code Index:

NAME

Top

Template::Plugin::Catalyst::View::PDF::Reuse

SYNOPSYS

Top

Template Toolkit plugin for PDF::Reuse

AUTHOR

Top

Jon Allen, jj@jonallen.info

SEE ALSO

Top

Penny's Arcade Open Source - http://www.pennysarcade.co.uk/opensource

COPYRIGHT & LICENSE

Top


Catalyst-View-PDF-Reuse documentation Contained in the Catalyst-View-PDF-Reuse distribution.

package Template::Plugin::Catalyst::View::PDF::Reuse::Barcode;

use strict;
use warnings;
use parent 'Template::Plugin';

our $AUTOLOAD;
our $target = 'PDF::Reuse::Barcode';

# Adapted from Template::Plugin::Procedural by Mark Fowler
sub load {
    my ($class, $context) = @_;

    my $proxy = "Template::Plugin::" . $class;
    eval "use $target";
    no strict "refs";
    if ($@) {
        my $error = $@;
        *{ $proxy . "::AUTOLOAD" } = sub {
            $AUTOLOAD =~ s!^.*::!!;
            die "Cannot load $target so unable to execute '$AUTOLOAD' in template - $error"
                unless ($AUTOLOAD eq 'DESTROY');
        };  
    } else {
        *{ $proxy . "::AUTOLOAD" } = sub {
            $AUTOLOAD =~ s!^.*::!!;
            if (my $method = $target->can($AUTOLOAD)) {
                shift @_;

                # Expand hashref arguments for PDF::Reuse::Barcode
                if (ref $_[0] eq 'HASH') {
                    splice @_,0,1,%{$_[0]};
                }

                goto $method;
            } else {
                warn "Cannot find method $AUTOLOAD in $target";
            }
        };  
    }

    *{ $proxy . "::new" } = sub {
        my $this;
        return bless \$this, $_[0];
    };
 
    return $proxy;
}


1;