File Coverage

blib/lib/Finance/Bank/Cahoot/CredentialsProvider/Callback.pm
Criterion Covered Total %
statement 24 24 100.0
branch 4 4 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             # Copyright (c) 2007 Jon Connell.
2             # All Rights Reserved.
3             #
4             # This program is free software; you can redistribute it and/or
5             # modify it under the same terms as Perl itself.
6              
7             package Finance::Bank::Cahoot::CredentialsProvider::Callback;
8 1     1   1038 use base qw(Finance::Bank::Cahoot::CredentialsProvider);
  1         3  
  1         692  
9              
10 1     1   6 use strict;
  1         3  
  1         27  
11 1     1   6 use warnings 'all';
  1         1  
  1         43  
12 1     1   6 use vars qw($VERSION);
  1         2  
  1         54  
13              
14             $VERSION = '1.07';
15              
16 1     1   8 use Carp qw(croak);
  1         2  
  1         219  
17              
18             sub _init
19             {
20 3     3   5 my ($self, $options) = @_;
21 3         4 while (my ($credential, $callback) = each %{$options}) {
  8         23  
22 7 100       49 croak 'Invalid credential '.$credential.' supplied with callback'
23             if not $self->can($credential);
24 6 100       125 croak 'Callback for '.$credential.' is not a code ref'
25             if ref $callback ne 'CODE';
26 5         24 $self->{$credential} = $callback;
27             }
28 1         4 return $self;
29             }
30              
31             sub get
32             {
33 7     7 1 10 my ($self, $credential, $offset) = @_;
34 7         18 return $self->{$credential}($offset);
35             }
36              
37             1;
38             __END__