« blib/lib/Lemonldap/NG/Portal/Password/Combination.pm
↑ Summary
blib/lib/Lemonldap/NG/Portal/Auth/Choice.pm »
| 1 | package Lemonldap::NG::Portal::Lib::LazyLoadedConfiguration; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 29 | ▶ | use Mouse::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 29 | requires qw(load_config); | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 60 | ▶ | has config_expires_at => ( is => 'rw', default => sub { {} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 60 | ▶ | has config_is_loaded => ( is => 'rw', default => sub { {} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 60 | ▶ | has config_info => ( is => 'rw', default => sub { {} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 119 | ▶ | sub lazy_load_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lazy_load_config: called CC=7 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 119 | my ( $self, $config_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 119 | my $expires_at = $self->config_expires_at->{$config_name}; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 119 | my $is_loaded = $self->config_is_loaded->{$config_name}; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 119 | ▶ | if ( $is_loaded and ( not defined $expires_at or time < $expires_at ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$is_loaded and !defined($expires_at) || &CORE::GLOBAL::time() < $expires_at
not defined $expires_at or &CORE::GLOBAL::time() < $expires_at
MC/DC33%1/3
$is_loaded and !defined($expires_at) || &CORE::GLOBAL::time() < $expires_at
$is_loaded
not defined $expires_at
&CORE::GLOBAL::time() < $expires_at
Truth table50%2/4
A and not(B) or C
A= $is_loadedB= not defined $expires_atC= &CORE::GLOBAL::time() < $expires_at
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # Already loaded, nothing to do | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 54 | $self->logger->debug("Config for $config_name is already loaded"); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 54 | return $self->config_info->{$config_name}; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 65 | $self->logger->debug("Reloading config for $config_name"); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 65 | my $config_result = $self->load_config($config_name); | |||||||||||||||||||||||||||||||||||||||||
| 24 | 65 | ▶ | if ($config_result) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 65 | $self->config_is_loaded->{$config_name} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 65 | my $ttl = $config_result->{ttl}; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 65 | ▶ | if ( defined $ttl ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $will_expire_at = time + $ttl; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $self->config_expires_at->{$config_name} = $will_expire_at; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $self->logger->debug( | |||||||||||||||||||||||||||||||||||||||||
| 31 | "Config for $config_name will be valid until $will_expire_at" | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 65 | my $info = $config_result->{info}; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 65 | ▶ | $self->config_info->{$config_name} = $info if $info; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 65 | return $info; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 29 | 1; | |||||||||||||||||||||||||||||||||||||||||