From a92dc45aee3f599926c77294328db38c5b2544eb Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Fri, 3 Apr 2015 10:40:28 +0300 Subject: docs: describe functionality used in the dnsmasq module --- aconf/model/model.lua | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'aconf/model/model.lua') diff --git a/aconf/model/model.lua b/aconf/model/model.lua index 3ffd4d3..20e2551 100644 --- a/aconf/model/model.lua +++ b/aconf/model/model.lua @@ -67,13 +67,15 @@ function M.Action:meta(context) end ---- create a new model. The model's fields can be defined after its --- creation 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 a subclass --- of Model. --- @tparam ?Model base base model inherited by the new model --- @treturn Model new model +--- 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>**. +-- @function new +-- @param base (optional **<Model>**) base model +-- inherited by the new model. +-- @return **<Model>** new model function M.new(base) if not base then base = M.Model end @@ -106,6 +108,9 @@ function M.new(base) return res end +--- Model objects. Each of these represents an actual model +-- object in the data model, in the context of a specific transaction. +-- @section Model M.Model = M.new(node.TreeNode) function M.Model:init(context) @@ -243,6 +248,15 @@ function M.Model:init(context) for _, f in ipairs(_members(Model)) do tload(f.name) end end +--- fetch an object in the context of the model object's transaction. +-- @function Model:fetch +-- @tparam string path path of the object to fetch. A path relative to +-- the model object's own path may be used. +-- @return (**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. function M.Model:fetch(path, create) return getmetatable(self).fetch(path, create) end -- cgit v1.2.3