File: Simple.pm

package info (click to toggle)
libconfig-onion-perl 1.007-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 192 kB
  • ctags: 19
  • sloc: perl: 151; makefile: 12
file content (95 lines) | stat: -rw-r--r-- 1,873 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package Config::Onion::Simple;

use strict;
use warnings;

our $VERSION = 1.004;

use Config::Onion;

use base 'Exporter';
BEGIN {
  our @EXPORT = ();
  our @EXPORT_OK = qw(
    cfg
    cfg_obj
  );
  our %EXPORT_TAGS = (
    all         => [ @EXPORT, @EXPORT_OK ],
  );
}

my $cfg_obj;

sub cfg { cfg_obj()->get }

sub cfg_obj { $cfg_obj ||= Config::Onion->new }

1;

=pod

=encoding UTF-8

=head1 NAME

Config::Onion::Simple - Simple interface to a Config::Onion singleton

=head1 VERSION

version 1.007

=head1 SYNOPSIS

  use Config::Onion::Simple qw( cfg cfg_obj );

  cfg_obj->load('myapp');
  my $setting = cfg->{setting};

=head1 DESCRIPTION

It is often useful for a single master configuration to be shared across
multiple modules in an application.  Config::Onion::Simple provides an
interface to do this without requiring any of those modules to know about
each other.

=head1 EXPORTABLE FUNCTIONS

Config::Onion::Simple exports nothing by default.  The following functions
are exported only on request.

=head2 cfg

Returns a reference to the complete configuration hash managed by the
Config::Onion singleton.  This hash should be treated as read-only, as any
changes will be lost if the configuration is altered using the underlying
Config::Onion instance's methods.

Calling C<cfg> is equivalent to calling C<< cfg_obj->get >>.

=head2 cfg_obj

Returns a reference to the Config::Onion singleton.  Use this object's methods
to make any changes to the configuration.

=head1 SEE ALSO

L<Config::Onion>

=head1 AUTHOR

Dave Sherohman <dsheroh@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Lund University Library.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

__END__

# ABSTRACT: Simple interface to a Config::Onion singleton