Module corky.options

Functions dealing with general options for Corky modules.

Setting an option:

#: config, <option>, <value>

All parameters are mandatory, additional parameters are not allowed. No validation is performed, values will be set as they appear in the configuration file (as strings). The name of the option must already be known to this module, trying to set an unknown option in the configuration file is not possible.

Developer information:

An option must have been set using the set() function before it is used in the configuration file, else it will be ignored!

It is recommended to use the full module name as prefix for an option. For example, the corky.cache module defines the corky.cache.default_update_interval option.

See the source of the corky.cache module for an example.

Info:

  • Copyright: © 2015-2017 Stefan Göbel
  • Release: 2017033001
  • License: GPLv3
  • Author: Stefan Göbel [⌂] [✉]

Functions

set (option, value[, callback]) Set the specified option to the specified value.
get (option) Get the current value of the specified option.

Local Functions

config_handler (setting) Configuration handler for cache settings.

Local Tables

options Stores the general configuration options.
callbacks Stores the callbacks.


Functions

set (option, value[, callback]) line 82
Set the specified option to the specified value.

Note that setting an option to nil will effectively delete this option.

A callback function may be provided as third parameter. The function will be called when the option is set in the configuration file. It will be called with two parameters: the option name and the new value of the option, in that order. If a callback is set, the value will not be set automatically when the configuration is parsed, it has to be set in the callback function using set()! The callback function has to return true for valid options, or false for invalid options (in which case an error message will be displayed).

A callback function may be removed by setting the third parameter to false. Not setting the third parameter will not change the currently set (or not set) callback function.

Parameters:

  • option string The name of the option to set.
  • value The value of the option.
  • callback Either a function, or false. See above for details. (optional)
get (option) line 103
Get the current value of the specified option.

Parameters:

  • option string The name of the option.

Returns:

  1. The current value of the option.

Local Functions

config_handler (setting) line 120
Configuration handler for cache settings.

This handler will be called automatically for every option directive in the configuration file.

Parameters:

  • setting table Array containing the configuration directive split into its individual parts.

Returns:

  1. bool If successful true, false in case of any error.

See also:

Local Tables

options line 52
Stores the general configuration options.

The keys are the options names (arbitrary non-empty strings), the values are the option values.

callbacks line 58
Stores the callbacks.

The keys are the options names (same as in options), the values are the callback functions.

generated by LDoc 1.4.6 Last updated 2019-02-14 20:51:07