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

NAME

OpusVL::SysParams - Module to handle system wide parameters

VERSION

version 0.20

SYNOPSIS

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);
    ...

METHODS

new

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

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_or_set

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

$default_sub - A CODEREF returning the default value. $params (your instance of OpusVL::SysParams) is passed as the first argument.

$type - We will try to determine the type from your $default_sub, but if it's unclear, you may wish to be explicit here.

Example:

   $params->get_or_set('partner.titles', sub { 'Mr|Mrs|Miss|Mx' });

del

Delete a system parameter. The key name is simply a string.

key_names

Returns the keys of the system parameters.

set

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_json

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.

get_json

Returns the value encoded in json. Primarily for talking with web interfaces.

SUPPORT

If you require assistance, support, or further development of this software, please contact OpusVL using the details below:

AUTHOR

OpusVL - www.opusvl.com

COPYRIGHT AND LICENSE

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.