| 1 | # | ||||||||||||||||||||
| 2 | # This file is part of WWW-DaysOfWonder-Memoir44 | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # This software is copyright (c) 2009 by Jerome Quelin. | ||||||||||||||||||||
| 5 | # | ||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 8 | # | ||||||||||||||||||||
| 9 | 4 | ▶ | use 5.012; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | package WWW::DaysOfWonder::Memoir44::DB::Params; | ||||||||||||||||||||
| 14 | # ABSTRACT: various runtime params | ||||||||||||||||||||
| 15 | 4 | $WWW::DaysOfWonder::Memoir44::DB::Params::VERSION = '3.000'; | |||||||||||||||||||
| 16 | 4 | ▶ | use Config::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 4 | ▶ | use MooseX::Singleton; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 4 | ▶ | use MooseX::Has::Sugar; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 4 | ▶ | use WWW::DaysOfWonder::Memoir44::Utils qw{ $DATADIR }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 4 | my $params_file = $DATADIR->file( "params.ini" ); | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 4 | has _params => ( ro, isa => "Config::Tiny", lazy_build ); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | sub _build__params { | ||||||||||||||||||
|
Subroutine
_build__params: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 28 | 0 | my $self = shift; | |||||||||||||||||||
| 29 | 0 | my $params = Config::Tiny->read( $params_file ); | |||||||||||||||||||
| 30 | 0 | ▶ | $params //= Config::Tiny->new; | ||||||||||||||||||
|
Condition0%0/3
$params //= "Config::Tiny"->new
MC/DC0%0/2
$params //= "Config::Tiny"->new
$params
"Config::Tiny"->new
Truth table0%0/3
A //= B
A= $paramsB= "Config::Tiny"->new
| |||||||||||||||||||||
| 31 | 0 | return $params; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | # -- public methods | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | sub get { | ||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 38 | 0 | my ($self, $key) = @_; | |||||||||||||||||||
| 39 | 0 | my $section = scalar caller; | |||||||||||||||||||
| 40 | 0 | return $self->_params->{ $section }->{ $key }; | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | ▶ | sub set { | ||||||||||||||||||
|
Subroutine
set: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 46 | 0 | my ($self, $key, $value) = @_; | |||||||||||||||||||
| 47 | 0 | my $section = scalar caller; | |||||||||||||||||||
| 48 | 0 | my $params = $self->_params; | |||||||||||||||||||
| 49 | 0 | $params->{ $section }->{ $key } = $value; | |||||||||||||||||||
| 50 | 0 | $params->write( $params_file ); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 4 | 1; | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||