blib/lib/Template/Plugin.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 32 CC 1 SCAR 6.9
CC
1
Cov
0%
load
2.0
new
2.0
fail
2.0
CRAP 2.0
1 #============================================================= -*-Perl-*-
2 #
3 # Template::Plugin
4 #
5 # DESCRIPTION
6 #
7 # Module defining a base class for a plugin object which can be loaded
8 # and instantiated via the USE directive.
9 #
10 # AUTHOR
11 # Andy Wardley <abw@wardley.org>
12 #
13 # COPYRIGHT
14 # Copyright (C) 1996-2022 Andy Wardley. All Rights Reserved.
15 #
16 # This module is free software; you can redistribute it an/or
17 # modify it under the same terms as Perl itself.
18 #
19 #============================================================================
20  
21 package Template::Plugin;
22  
23 use strict;
24 use warnings;
25 use base 'Template::Base';
26  
27 our $VERSION = '3.100';
28 our $DEBUG = 0 unless defined $DEBUG;
29 our $ERROR = '';
30 our $AUTOLOAD;
31  
32  
33 #========================================================================
34 # ----- CLASS METHODS -----
35 #========================================================================
36  
37 #------------------------------------------------------------------------
38 # load()
39 #
40 # Class method called when the plugin module is first loaded. It
41 # returns the name of a class (by default, its own class) or a prototype
42 # object which will be used to instantiate new objects. The new()
43 # method is then called against the class name (class method) or
44 # prototype object (object method) to create a new instances of the
45 # object.
46 #------------------------------------------------------------------------
47  
48 sub load {
49 return $_[0];
50 }
51  
52  
53 #------------------------------------------------------------------------
54 # new($context, $delegate, @params)
55 #
56 # Object constructor which is called by the Template::Context to
57 # instantiate a new Plugin object. This base class constructor is
58 # used as a general mechanism to load and delegate to other Perl
59 # modules. The context is passed as the first parameter, followed by
60 # a reference to a delegate object or the name of the module which
61 # should be loaded and instantiated. Any additional parameters passed
62 # to the USE directive are forwarded to the new() constructor.
63 #
64 # A plugin object is returned which has an AUTOLOAD method to delegate
65 # requests to the underlying object.
66 #------------------------------------------------------------------------
67  
68 sub new {
69 my $class = shift;
70 bless {
71 }, $class;
72 }
73  
74 #------------------------------------------------------------------------
75 # fail($error)
76 #
77 # Version 1 error reporting function, now replaced by error() inherited
78 # from Template::Base. Raises a "deprecated function" warning and then
79 # calls error().
80 #------------------------------------------------------------------------
81  
82 sub fail {
83 my $class = shift;
84 my ($pkg, $file, $line) = caller();
85 warn "Template::Plugin::fail() is deprecated at $file line $line. Please use error()\n";
86 $class->error(@_);
87 }
88  
89 1;
90  
91 __END__