Andrew Sterling Hanenkamp > Contentment-0.011_033 > Contentment::Setting

Download:
Contentment-0.011_033.tar.gz

Dependencies

Annotate this POD

Module Version: 0.12   Source  

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.

CONTEXT

This class adds the following methods to the context:

$settings = $context->settings

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 careful 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 explicitly notifying the settings object. For example:
      my $settings = $context->settings;
      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.

syntax highlighting: