Benjamin Tietz > User-Config-0.02_01 > User::Config::DB

Download:
User-Config-0.02_01.tar.gz

Dependencies

Annotate this POD

Module Version: 0.01_01   Source  

NAME ^

User::Config::DB - This defines the role, the database-backends are playing.

DESCRIPTION ^

To store the value, a user set for a given option, User::Config uses a database-backend. These backends must live within the namespace User::Config::DB:: and consume this role.

CONSUMER-METHODS

The interface was held as simple as possible. To consume this role, the following methods have to be implemented.

<$db-set($package, $user, $option_name, $context, $value)>>

The set method has to be implemented. Whenever a user sets a speicific option to a new value, this method is called and has to take care of storing this piece of information.

The parameters are as following:

$package

Contains the package or namespace for the module in question. This usally is the package-name of the module, declaring the option.

$user

The name of the current contexts user.

$option_name

The name of the option to set ( within the package ).

$context

The current context.

$value

The new value to set.

<$db-get($package, $user, $option_name, $context)>>

The get method has to be implemented by the corresponding backend. It returns the previous set value or undef, if no value was set.

The parameters work are the same as for set.

<$db-isset($package, $user, $option_name, $context)>>

Optionally, the backend can implement the isset-method. This will be called before get is called. If the user has set this option in advance, the method should return true. If not, false should be returned. Then get isn't called at all and the default value will be submitted to the caller.

The parameters work are the same as for set.

If this isn't implemented get is always called. The default value will then be returned, if get returns undef.

INTERNALS

The following information aren't needed to write new code. There here for completness only.

While set is just checking, wether the user is valid, get is completly wrapped in this role. The wrapper checks wether the backend implements isset and returns the user-set value or the default, if the setting isn't stored.

The default value is given while the option is declared. If the default value is a code-reference, the code is called. The returned value is immediatly saved in the backend, so that it get's returned the next time the option is retrieved.

SEE ALSO ^

User::Config User::Config::DB::DBIC User::Config::DB::Ldap User::Config::DB::Keyed

Further backends are welcome.

AUTHOR ^

Benjamin Tietz <benjamin@micronet24.de>

COPYRIGHT AND LICENSE ^

Copyright (C) 2011 by Benjamin Tietz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: