diff options
Diffstat (limited to 'acf/model/model.lua')
-rw-r--r-- | acf/model/model.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/acf/model/model.lua b/acf/model/model.lua index 365fe20..e94d3fb 100644 --- a/acf/model/model.lua +++ b/acf/model/model.lua @@ -71,18 +71,20 @@ function Model:init(context) return isinstance(res, Field) and node.BoundField(self, res) or nil end + function mt.has_field(name) return mt.field(name) end + function mt.mmeta(name) return mt.field(name):meta() end - function mt.get(k) + function mt.load(k, create) local f = mt.field(k) if f then if f.compute then return f:compute() end - return f:load() + return f:load(create) end return mt.class[k] end - function mt.set(k, v) + function mt.save(k, v) local f = mt.field(k) if not f then raise(mt.path, 'Field named '..k..' does not exist') end f:save(v) |