Changeset 22 for LATMOS-Accounts
- Timestamp:
- 04/10/09 16:14:23 (15 years ago)
- Location:
- LATMOS-Accounts
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts.pm
r3 r22 4 4 use strict; 5 5 use warnings; 6 use base qw(Config::IniFiles); 7 use LATMOS::Accounts::Bases; 6 8 7 require Exporter;9 our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 8 10 9 our @ISA = qw(Exporter); 11 sub new { 12 my ($class, $config) = @_; 10 13 11 # Items to export into callers namespace by default. Note: do not export 12 # names by default without a very good reason. Use EXPORT_OK instead. 13 # Do not simply export all your public functions/methods/constants. 14 my $self = Config::IniFiles->new( 15 -file => $config 16 ); 14 17 15 # This allows declaration use LATMOS::Accounts ':all'; 16 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK 17 # will save memory. 18 our %EXPORT_TAGS = ( 'all' => [ qw( 19 20 ) ] ); 18 bless($self, $class) 19 } 21 20 22 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); 21 sub base { 22 my ($self, $section) = @_; 23 # this method perform a cache 24 $self->{_bases}{$section} and return $self->{_bases}{$section}; 25 $self->load_base($section) ? $self->{_bases}{$section} : undef; 26 } 23 27 24 our @EXPORT = qw( 25 26 ); 28 # load or reload a base 29 sub load_base { 30 my ($self, $section) = @_; 31 return ($self->{_bases}{$section} = $self->_load_base($section)) 32 ? 1 33 : 0; 34 } 27 35 28 our $VERSION = '0.01'; 29 30 31 # Preloaded methods go here. 36 # do the bad work 37 sub _load_base { 38 my ($self, $section) = @_; 39 my $type = $self->val($section, 'type') or return; 40 my %params = map { $_ => ($self->val($section, $_) || undef) } $self->Parameters($section); 41 return LATMOS::Accounts::Bases->new($type, %params); 42 } 32 43 33 44 1;
Note: See TracChangeset
for help on using the changeset viewer.