OpusVL::SysParams - Module to handle system wide parameters
version 0.20
This module handles system wide parameters.
use OpusVL::SysParams; my $sys_param = OpusVL::SysParams->new(); # or my $sys_param = OpusVL::SysParams->new({ schema => $schema}); my $val = $sys_param->get('login.failures'); $sys_param->set('login.failures', 3); ...
If the constructor is called without a schema specified it will attempt to load up a schema based on a config file in the catalyst style for the name 'OpusVL::SysParams'. This config file should have a Model::SysParams section containing the config.
<Model::SysParams> connect_info dbi:Pg:dbname=test1 connect_info user connect_info password </Model::SysParams>
Note that you must specify at least 2 connect_info parameters even if you are using SQLite otherwise the code will crash.
Get a system parameter. The key name is simply a string. It's suggested you use some kind of schema like 'system.key' to prevent name clashes with other unoriginal programmers.
Get a system parameter, setting it to a default if it doesn't already exist.
$params->get_or_set($name, $default_sub);
$name - the name of the system parameter
$name
$default_sub - A CODEREF returning the default value. $params (your instance of OpusVL::SysParams) is passed as the first argument.
$default_sub
$params
$type - We will try to determine the type from your $default_sub, but if it's unclear, you may wish to be explicit here.
$type
Example:
$params->get_or_set('partner.titles', sub { 'Mr|Mrs|Miss|Mx' });
Delete a system parameter. The key name is simply a string.
Returns the keys of the system parameters.
Set a system parameter. The key name is simply a string. It's suggested you use some kind of schema like 'system.key' to prevent name clashes with other unoriginal programmers.
The value can be any data structure so long as it doesn't contain code.
Set a system parameter. This allows you to pass the object encoded as JSON in order to make it simpler for web interfaces to talk to the settings.
Returns the value encoded in json. Primarily for talking with web interfaces.
If you require assistance, support, or further development of this software, please contact OpusVL using the details below:
Telephone: +44 (0)1788 298 410
Email: community@opusvl.com
Web: http://opusvl.com
OpusVL - www.opusvl.com
This software is copyright (c) 2011 - 2016 by OpusVL - www.opusvl.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install OpusVL::SysParams, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpusVL::SysParams
CPAN shell
perl -MCPAN -e shell install OpusVL::SysParams
For more information on module installation, please visit the detailed CPAN module installation guide.