Finance::Bank::Cahoot::CredentialsProvider - Abstract base class for credentials providers
my $credentials = Finance::Bank::Cahoot::CredentialsProvider::Acme->new( credentials => [qw(account password)], options => {account => 'acmeuser'});
Provides an abstract base class for deriving new credentials providers with a defined interface. Derived classes MUST implement _init and get methods.
_init
get
Create a new instance of a credentials provider. Each credential is available with its own access method of the same name. All methods may be optionally supplied a character offset in the credentials value (first character is 0).
Initialization routine for the derived class to implement. Called by new with the credentials options as a hash reference. In the following example, taken from the the Constant credentials provider, _init simply stores each option value in the class:
new
Constant
sub _init { my ($self, $options) = @_; while (my ($credential, $value) = each %{$options}) { croak 'Invalid credential '.$credential.' supplied with callback' if not $self->can($credential); $self->{$credential} = $value; } }
Public access method for the derived class to implement. Called with the name of the credential to supply and an optional character offset (0 is the first character). In the following example, taken from the the Constant credentials provider, the credential is simply returned from class members created by the previous _init method:
sub get { my ($self, $credential, $offset) = @_; return substr ($self->{$credential}, $offset, 1) if defined $offset; return $self->{$credential}; }
Jon Connell <jon@figsandfudge.com>
This module takes its inspiration from Finance::Bank::Natwest by Jody Belka.
Copyright 2007 by Jon Connell
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Finance::Bank::Cahoot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Finance::Bank::Cahoot
CPAN shell
perl -MCPAN -e shell install Finance::Bank::Cahoot
For more information on module installation, please visit the detailed CPAN module installation guide.