Config-Onion

 view release on metacpan or  search on metacpan

lib/Config/Onion.pm  view on Meta::CPAN


=head1 PROPERTIES

=head2 cfg

=head2 get

Returns the complete configuration as a hash reference.

=head2 default

=head2 main

=head2 local

=head2 override

These properties each return a single layer of the configuration.  This is
not likely to be useful other than for debugging.  For most other purposes,
you probably want to use C<get> instead.

=head2 prefix_key

If set, enables the Prefix Structures functionality described below when using
the C<load> or C<load_glob> methods.  The value of C<prefix_key> specifies the
name of the key under which the  prefix structure may be found.

Default value is C<undef>.

=head1 Prefix Structures

If you find that your configuration structure is becoming unwieldy due to
deeply-nested structures, you can define a file-specific "prefix structure"
and all other settings within that file will be loaded as children of the
prefix structure.  For example, if your main program uses

  $cfg = Config::Onion->new(prefix_key => '_prefix');
  $cfg->load("myapp/config");

and C<myapp/config.yml> contains

  _prefix:
    foo:
      bar:

  baz: 1

then C<$cfg> will contain the configuration

  foo:
    bar:
      baz: 1

Note that the top-level C<prefix_key> is removed.

There are some limitations on the prefix structure, in order to keep it sane
and deterministic.  First, the prefix structure may only contain hashes.
Second, each hash must contain exactly one key.  Finally, the value associated
with the final key must be left undefined.

=head1 BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests at
L<https://github.com/dsheroh/Config-Onion/issues>

=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: Layered configuration, because configs are like ogres



( run in 2.541 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )