The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Contentment::Setting - A Contentment plugin for storing configuration

DESCRIPTION

This module is required by the Contentment core and is used to store settings and configuration information in the database.

$settings = Contentment::Setting->instance

Returns a reference to a hash containing all the settings. Settings are permanently saved to the database when changed.

This hash can be used to store most complex types. It uses YAML to encode all the values, which can encode just about anything.

However, there are a few caveats to be creaful about:

  • References to blessed items or types other than scalars, hashes, or arrays might not store and load again quite as you expect. In particular, objects can be blessed into classes that aren't even loaded.

  • Be careful modifying deep parts of the code without tellings the settings. For example:

      my $settings = Contentment::Setting->instance;
      my %hash = ( foo => 1, bar => 2 );
    
      # Works great!
      $settings->{blah} = \%hash;
    
      $hash{baz} = 3;
    
      # Bad stuff! Outputs: foo, bar
      # $settings doesn't know about baz!
      print(join(', ', keys %$settings),"\n");
    
      # Make sure you always notify the hash of deep changes:
      $settings->{blah} = \%hash;

AUTHOR

Andrew Sterling Hanenkamp, <hanenkamp@users.sourceforge.net>

LICENSE AND COPYRIGHT

Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved.

Contentment is distributed and licensed under the same terms as Perl itself.