Module aconf.model

Functions

new (base) create a new model, representing a data model with a pre-defined structure.
node.insert (list, v, i) inserts a member to a list or set
permission.defaults (path) create default permissions (read, create, modify, delete) for a given path.
register (name, field, params) inject a new field to the root model.
service (name) create a model corresponding to an OpenRC service.
node.contains (set, v) determines if the given set contains the given value.

Classes

Field base class for fields.
String string field, inherits Field.
Boolean boolean field, inherits Field.
Model model field, inherits Field.
Collection collection field, inherits Field.
List list field, inherits Collection.
Set set field, inherits Collection.
net.IPAddress IP address field, inherits Field.
net.DomainName domain name field, inherits String.
node.TreeNode non-leaf object.
node.List list object, inherits node.TreeNode.
node.Set set object, inherits node.List.

Model objects

Model:fetch (path) fetch an object in the context of the model object's transaction.


Functions

new (base)
create a new model, representing a data model with a pre-defined structure. The model's fields can be defined by assigning it key–value pairs. The key will be the name of the field and the value will determine its type. The value shall be a subclass of Field, an instance of such, or another <Model>.

Parameters:

  • base (optional <Model>) base model inherited by the new model.

Returns:

    <Model> new model
node.insert (list, v, i)
inserts a member to a list or set

Parameters:

  • list node.List list or set
  • v value to be inserted
  • i optional int index. By default, the element is inserted at the end of the list. This parameter is not applicable when inserting to a node.Set instance.
permission.defaults (path)
create default permissions (read, create, modify, delete) for a given path.

Parameters:

  • path string path to create the permissions for
register (name, field, params)
inject a new field to the root model.

Parameters:

service (name)
create a model corresponding to an OpenRC service.

Parameters:

  • name string name of the service

Returns:

    (<Model>) new model which has two pre-defined boolean fields, enabled and status, for controlling the service's lifecycle and inspecting its current status.
node.contains (set, v)
determines if the given set contains the given value.

Parameters:

Returns:

    boolean true if the set contains the value

Classes

Field
base class for fields. The constructor accepts a table argument containing field parameters as key–value pairs. The parameters listed below are valid for all subclasses. Subclasses may define additional parameters.

Constructor parameters:

  • addr optional string back-end address for the field. This can be an absolute address or relative to the parent's address. The top-level component of a back-end address specifies the back-end. The interpretation of the remaining components is specific to the back-end. If not specified, the address is formed by appending the field's name to the address of the parent.
  • be_mode (optional string or {[string]=string,...}) controls how the Augeas back-end will map addresses to Augeas paths. By default, each component of a back-end address is directly mapped to an Augeas path component. This parameter is an exception table applicable to the subtree defined by the field's address. Each key is a relative address pattern, and the corresponding value is a directive applied to matching address components. The enumerate directive indicates there can be several Augeas nodes matching the path and the next component is to be interpreted as an index for such nodes. The parent-value directive is applicable only to primitive fields and instructs the back-end not to append the last address component at all, causing the parent node's value to be accessed. If the be_mode parameter is defined as a string, it is assumed to be a directive applicable to the field's own address.
  • choice (optional {primitive or {primitive,string},...}) array of allowed values. Each value may be a primitive value or a tuple specifying the value used by the data model and a user-friendly value.
  • compute (optional function(node.TreeNode) or string) function for computing the value of the field when not provided by the back-end. The function gets a reference to the field's parent as an argument. If defined as a string, a method with the given name is invoked.
  • default optional primitive default value for the field
  • required optional boolean field must be assigned a value if set, defaults to false
  • store (optional function(node.TreeNode, primitive) or string) if this parameter is defined, the value of the field is not stored according to the field's back-end address. Rather, the provided function is invoked with a reference to the parent and the field value. If defined as a string, a method with the given name is invoked.
  • ui_name optional string user-friendly name for the field.
  • visible optional boolean the field is visible in the user interface if set, defaults to true
  • widget optional string widget for rendering the field in the user interface. The default widget for non-leaf objects is link, which is a hyperlink to a detailed view to the object. The inline widget renders a non-leaf object embedded in the parent's view.
String
string field, inherits Field.
Boolean
boolean field, inherits Field.
Model
model field, inherits Field. The value of this field is a model object conforming to the specified model. A model field with default parameters is implicitly created when a model is used in lieu of a Field.

Constructor parameters:

  • model (<Model>) model describing the structure of the model objects
Collection
collection field, inherits Field.

Constructor parameters:

  • type (Field or <Model>) subclass of Field, instance of such, or <Model> specifying the type of the members.
  • ui_member optional string user-friendly noun for a member of this collection
List
list field, inherits Collection. The value of this field is an instance of node.List.
Set
set field, inherits Collection. The value of this field is an instance of node.Set.
net.IPAddress
IP address field, inherits Field. Accepts both IPv4 and IPv6 address values.
net.DomainName
domain name field, inherits String.
node.TreeNode
non-leaf object. An instance of this class represents a non-leaf object in the data model, in the context of a specific transaction. These instances appear as Lua tables, such that their children may be read and written by using their relative path name as the key. If the child is of complex type, it is possible to assign a structure of Lua tables as the value. This results in replacing the entire subtree with the provided sturcture. Providing a string in lieu of a complex value is handled by interpreting the string as a path and copying the subtree it refers to.
node.List
list object, inherits node.TreeNode. An instance of this class represents a list object in the data model, in the context of a specific transaction. A list is an ordered collection of members. The path of a list member is that of the list augmented by the index of the member.
node.Set
set object, inherits node.List. An instance of this class represents a set object in the data model, in the context of a specific transaction. A set is an unordered collection of primitive values. Members can be inserted to the set using node.insert. Members can be removed by assigning the nil value to the key to be removed.

Model objects

Each of these represents an actual model object in the data model, in the context of a specific transaction.
Model:fetch (path)
fetch an object in the context of the model object's transaction.

Parameters:

  • path string path of the object to fetch. A path relative to the model object's own path may be used.

Returns:

    (primitive or node.TreeNode) fetched object. An instance of node.TreeNode represents a non-leaf object in the data model, in the context of a specific transaction. Model objects themselves are a special case of such objects.
generated by LDoc 1.4.3 Last updated 2015-11-12 23:45:13