File Coverage

blib/lib/Authen/PAAS/SimpleCallback.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition 1 3 33.3
subroutine 5 5 100.0
pod 2 2 100.0
total 25 27 92.5


line stmt bran cond sub pod time code
1             # -*- perl -*-
2             #
3             # Authen::PAAS::SimpleCallback by Daniel Berrange
4             #
5             # Copyright (C) 2004-2006 Dan Berrange
6             #
7             # This program is free software; you can redistribute it and/or modify
8             # it under the terms of the GNU General Public License as published by
9             # the Free Software Foundation; either version 2 of the License, or
10             # (at your option) any later version.
11             #
12             # This program is distributed in the hope that it will be useful,
13             # but WITHOUT ANY WARRANTY; without even the implied warranty of
14             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15             # GNU General Public License for more details.
16             #
17             # You should have received a copy of the GNU General Public License
18             # along with this program; if not, write to the Free Software
19             # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20             #
21             # $Id: SimpleCallback.pm,v 1.1 2005/04/23 22:45:36 dan Exp $
22              
23             =pod
24              
25             =head1 NAME
26              
27             Authen::PAAS::SimpleCallback - A callback implementation with static data
28              
29             =head1 SYNOPSIS
30              
31             use Authen::PAAS::SimpleCallback;
32              
33             my $cb = Authen::PAAS::SimpleCallback->new(data => "joe");
34              
35             print $cb->data, "\n";
36              
37             =head1 DESCRIPTION
38              
39             This module provides a trivial subclass of the L
40             which always returns a pre-defined chunk of static data.
41              
42             =head1 METHODS
43              
44             =over 4
45              
46             =cut
47              
48             package Authen::PAAS::SimpleCallback;
49              
50 2     2   44564 use base qw(Authen::PAAS::Callback);
  2         3  
  2         1236  
51              
52 2     2   13 use strict;
  2         4  
  2         59  
53 2     2   11 use warnings;
  2         4  
  2         248  
54              
55             our $VERSION = '1.0.0';
56              
57              
58             =item $cb = Authen::PAAS::SimpleCallback->new(data => $data);
59              
60             Create a new callback object which will later provide the piece
61             of static data defined by the C parameter. The data can be
62             of an arbitrary Perl data type, it is treated opaquely by this
63             module.
64              
65             =cut
66              
67             sub new {
68 7     7 1 2467 my $proto = shift;
69 7   33     56 my $class = ref($proto) || $proto;
70 7         44 my $self = $class->SUPER::new();
71              
72 7         45 $self->{data} = shift;
73              
74 7         17 bless $self, $class;
75              
76 7         32 return $self;
77             }
78              
79             =item $cb->data;
80              
81             Retrieve the data associated with this callback object. The
82             returned data will be that which was orginally passed into
83             the constructor.
84              
85             =cut
86              
87             sub data {
88 7     7 1 1285 my $self = shift;
89 7         27 return $self->{data};
90             }
91              
92             1 # So that the require or use succeeds.
93              
94             __END__