1 | package LATMOS::Accounts; |
---|
2 | |
---|
3 | use 5.010000; |
---|
4 | use strict; |
---|
5 | use warnings; |
---|
6 | use base qw(Config::IniFiles); |
---|
7 | use LATMOS::Accounts::Bases; |
---|
8 | |
---|
9 | our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; |
---|
10 | |
---|
11 | sub new { |
---|
12 | my ($class, $config) = @_; |
---|
13 | |
---|
14 | my $self = Config::IniFiles->new( |
---|
15 | -file => $config |
---|
16 | ); |
---|
17 | |
---|
18 | bless($self, $class) |
---|
19 | } |
---|
20 | |
---|
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 | } |
---|
27 | |
---|
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 | } |
---|
35 | |
---|
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 | } |
---|
43 | |
---|
44 | 1; |
---|
45 | __END__ |
---|
46 | # Below is stub documentation for your module. You'd better edit it! |
---|
47 | |
---|
48 | =head1 NAME |
---|
49 | |
---|
50 | LATMOS::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 | |
---|
59 | Stub documentation for LATMOS::Accounts, created by h2xs. It looks like the |
---|
60 | author of the extension was negligent enough to leave the stub |
---|
61 | unedited. |
---|
62 | |
---|
63 | Blah blah blah. |
---|
64 | |
---|
65 | =head2 EXPORT |
---|
66 | |
---|
67 | None by default. |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | =head1 SEE ALSO |
---|
72 | |
---|
73 | Mention other useful documentation such as the documentation of |
---|
74 | related modules or operating system documentation (such as man pages |
---|
75 | in UNIX), or any relevant external documentation such as RFCs or |
---|
76 | standards. |
---|
77 | |
---|
78 | If you have a mailing list set up for your module, mention it here. |
---|
79 | |
---|
80 | If you have a web site set up for your module, mention it here. |
---|
81 | |
---|
82 | =head1 AUTHOR |
---|
83 | |
---|
84 | Thauvin Olivier, E<lt>olivier.thauvin.ipsl.fr@localdomainE<gt> |
---|
85 | |
---|
86 | =head1 COPYRIGHT AND LICENSE |
---|
87 | |
---|
88 | Copyright (C) 2009 by Thauvin Olivier |
---|
89 | |
---|
90 | This library is free software; you can redistribute it and/or modify |
---|
91 | it under the same terms as Perl itself, either Perl version 5.10.0 or, |
---|
92 | at your option, any later version of Perl 5 you may have available. |
---|
93 | |
---|
94 | |
---|
95 | =cut |
---|