summaryrefslogtreecommitdiffstats
path: root/aconf/model/model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'aconf/model/model.lua')
-rw-r--r--aconf/model/model.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/aconf/model/model.lua b/aconf/model/model.lua
index ba6d004..8c62535 100644
--- a/aconf/model/model.lua
+++ b/aconf/model/model.lua
@@ -72,10 +72,12 @@ end
-- key–value pairs. The key will be the name of the field and
-- the value will determine its type. The value shall be a [field
-- class](#Overview_of_field_classes), an instance of field, or
--- another **<Model>**.
+-- another **<Model>**. The model's behavior can be customized
+-- by overriding some of its [methods](#Model_objects).
-- @param base (optional <i>**&lt;Model&gt;**</i>) base model
-- inherited by the new model.
--- @return <i>**&lt;Model&gt;**</i> new model
+-- @return <i>**&lt;Model&gt;**</i> new model, subclass of
+-- @{node.TreeNode}
function M.new(base)
if not base then base = M.Model end
@@ -185,6 +187,10 @@ function M.Model:init(context)
if self.is_removable then
function mt.removable()
+ --- determine whether this model object can be removed from
+ -- the data model.
+ -- @function is_removable
+ -- @treturn boolean true if the object is removable
return mt.has_permission('delete') and self:is_removable()
end
end
@@ -238,6 +244,10 @@ function M.Model:init(context)
if self:match(f.condition or {}) then f:validate_saved()
elseif f:_editable() then f:_save() end
end
+ --- check the validity of the model. This method may raise an
+ -- error or change the values of the model's fields. By default,
+ -- this method is not implemented.
+ -- @function validate
if self.validate then self:validate() end
end