summaryrefslogtreecommitdiff
path: root/server/src/emmy/field.lua
blob: f9e9cbf6e786f2d86bb0a05b01f91a9e837f5634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local listMgr = require 'vm.list'

---@class EmmyField
local mt = {}
mt.__index = mt
mt.type = 'emmy.field'

function mt:getName()
    return self.name
end

function mt:getSource()
    return listMgr.get(self.source)
end

function mt:bindType(type)
    if type then
        self._bindType = type
    else
        return self._bindType
    end
end

function mt:bindValue(value)
    if value then
        self._bindValue = value
    else
        if self._bindValue then
            if not self._bindValue:getSource() then
                self._bindValue = nil
            end
        end
        return self._bindValue
    end
end

return function (manager, source)
    local self = setmetatable({
        name = source[2][1],
        source = source.id,
        visible = source[1],
        _manager = manager,
    }, mt)
    return self
end