source: LATMOS-Accounts/lib/LATMOS/Accounts.pm @ 22

Last change on this file since 22 was 22, checked in by nanardon, 15 years ago
  • start work on core of the system
  • Property svn:keywords set to Id Rev
File size: 2.1 KB
Line 
1package LATMOS::Accounts;
2
3use 5.010000;
4use strict;
5use warnings;
6use base qw(Config::IniFiles);
7use LATMOS::Accounts::Bases;
8
9our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0];
10
11sub new {
12    my ($class, $config) = @_;
13
14    my $self = Config::IniFiles->new(
15        -file => $config
16    );
17
18    bless($self, $class)
19}
20
21sub 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}
27
28# load or reload a base
29sub load_base {
30    my ($self, $section) = @_;
31    return ($self->{_bases}{$section} = $self->_load_base($section))
32        ? 1
33        : 0;
34}
35
36# do the bad work
37sub _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}
43
441;
45__END__
46# Below is stub documentation for your module. You'd better edit it!
47
48=head1 NAME
49
50LATMOS::Accounts - Perl extension for blah blah blah
51
52=head1 SYNOPSIS
53
54  use LATMOS::Accounts;
55  blah blah blah
56
57=head1 DESCRIPTION
58
59Stub documentation for LATMOS::Accounts, created by h2xs. It looks like the
60author of the extension was negligent enough to leave the stub
61unedited.
62
63Blah blah blah.
64
65=head2 EXPORT
66
67None by default.
68
69
70
71=head1 SEE ALSO
72
73Mention other useful documentation such as the documentation of
74related modules or operating system documentation (such as man pages
75in UNIX), or any relevant external documentation such as RFCs or
76standards.
77
78If you have a mailing list set up for your module, mention it here.
79
80If you have a web site set up for your module, mention it here.
81
82=head1 AUTHOR
83
84Thauvin Olivier, E<lt>olivier.thauvin.ipsl.fr@localdomainE<gt>
85
86=head1 COPYRIGHT AND LICENSE
87
88Copyright (C) 2009 by Thauvin Olivier
89
90This library is free software; you can redistribute it and/or modify
91it under the same terms as Perl itself, either Perl version 5.10.0 or,
92at your option, any later version of Perl 5 you may have available.
93
94
95=cut
Note: See TracBrowser for help on using the repository browser.