File Coverage

blib/lib/Finance/Bank/Cahoot/CredentialsProvider/Constant.pm
Criterion Covered Total %
statement 25 25 100.0
branch 5 6 83.3
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 38 39 97.4


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::Constant;
8 2     2   2158 use base qw(Finance::Bank::Cahoot::CredentialsProvider);
  2         4  
  2         196  
9              
10 2     2   10 use strict;
  2         11  
  2         60  
11 2     2   9 use warnings 'all';
  2         3  
  2         87  
12 2     2   8 use vars qw($VERSION);
  2         2  
  2         96  
13              
14             $VERSION = '1.07';
15              
16 2     2   9 use Carp qw(croak);
  2         2  
  2         416  
17              
18             sub _init
19             {
20 5     5   24 my ($self, $options) = @_;
21 5         7 while (my ($credential, $value) = each %{$options}) {
  15         39  
22 12 100       82 croak 'Invalid credential '.$credential.' supplied with callback'
23             if not $self->can($credential);
24 10         37 $self->{$credential} = $value;
25             }
26 3         8 return $self;
27             }
28              
29             sub get
30             {
31 12     12 1 18 my ($self, $credential, $offset) = @_;
32 12 50       26 croak 'Undefined credential '.$credential
33             if not exists $self->{$credential};
34 12 100       51 return substr $self->{$credential}, $offset - 1, 1
35             if defined $offset;
36 9         31 return $self->{$credential};
37             }
38              
39             1;
40              
41             __END__