From cc8acc5fa708b9f24369d71b5e982a0314ca64d7 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Fri, 9 Dec 2016 19:50:10 +0200 Subject: doc: describe functionality used in the network module --- aconf/model/model.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'aconf/model/model.lua') 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 **<Model>**) base model -- inherited by the new model. --- @return **<Model>** new model +-- @return **<Model>** 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 -- cgit v1.2.3