summaryrefslogtreecommitdiffstats
path: root/aconf/model/model.lua
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2015-04-03 10:40:28 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2015-04-10 18:17:00 +0300
commita92dc45aee3f599926c77294328db38c5b2544eb (patch)
tree0f31580b868245cabe733864f9d99901730c3279 /aconf/model/model.lua
parent3baaf91de453d35b095881478be8d88b3fc2b97a (diff)
downloadaconf-a92dc45aee3f599926c77294328db38c5b2544eb.tar.bz2
aconf-a92dc45aee3f599926c77294328db38c5b2544eb.tar.xz
docs: describe functionality used in the dnsmasq modulev0.5.0
Diffstat (limited to 'aconf/model/model.lua')
-rw-r--r--aconf/model/model.lua28
1 files changed, 21 insertions, 7 deletions
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&ndash;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&ndash;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 **&lt;Model&gt;**.
+-- @function new
+-- @param base (optional <i>**&lt;Model&gt;**</i>) base model
+-- inherited by the new model.
+-- @return <i>**&lt;Model&gt;**</i> 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 (<i>**primitive**</i> or <i>@{node.TreeNode}</i>) 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