diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-05-01 09:25:44 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-05-01 14:10:59 +0300 |
commit | 0cd6597bec4f1b5c727cedcefe40085c6aa43c3b (patch) | |
tree | 37560799b03180436aafa8a72d86b94c7345d027 /acf/model/init.lua | |
parent | 13eb04abbc9d8561e44786ce9b0dd94bc1454e1f (diff) | |
download | aconf-0cd6597bec4f1b5c727cedcefe40085c6aa43c3b.tar.bz2 aconf-0cd6597bec4f1b5c727cedcefe40085c6aa43c3b.tar.xz |
make persistence manager aware of data types
coerce values into proper types
Diffstat (limited to 'acf/model/init.lua')
-rw-r--r-- | acf/model/init.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/acf/model/init.lua b/acf/model/init.lua index 00fc7aa..1bc190d 100644 --- a/acf/model/init.lua +++ b/acf/model/init.lua @@ -129,7 +129,8 @@ function Reference:meta(context) local txn = context.txn local objs = txn:get( - node.addr(relabel('system', txn.search, txn, res.scope)) + node.addr(relabel('system', txn.search, txn, res.scope)), + 'table' ) or {} res.choice = map(function(p) return pth.join(res.scope, p) end, objs) res['ui-choice'] = objs @@ -209,15 +210,16 @@ Mixed = class(Collection) function Mixed:init(params) params.type = Mixed super(self, Mixed):init(params, node.Mixed) + self.pfield = Field() end function Mixed:load(context) - local value = Primitive.load(self, context) + local value = self.pfield:load(context) if type(value) == 'table' then return super(self, Mixed):load(context) end return value end function Mixed:save(context, value) if type(value) == 'table' then super(self, Mixed):save(context, value) - else Primitive.save(self, context, value) end + else self.pfield:save(context, value) end end |