--
-- Created by IntelliJ IDEA.
-- User: Chev
-- Date: 2016-10-27
-- Time: 8:08 PM
-- To change this template use File | Settings | File Templates.
--
local pairs = pairs

LOOA = LOOA or {};

function LOOA:Class (template)
  local c = {};

  function c:New ()
    local inst = {
      const = {},
      private = {},
      public = {},
    };

    for k,v in pairs(template.const or {}) do
      inst.const[k] = v
    end

    for k,v in pairs(template.private or {}) do
      inst.private[k] = v
    end

    for k,v in pairs(template.public or {}) do
      inst.public[k] = v
    end

    local get = function(p)
      return inst.const[p] or inst.public[p]
    end

    local set = function(p, v)
      if inst.public[p] then
        inst.public[p] = v
      end
    end

    local vis = {
      set = set,
      get = get,
    };

    if template.privateFunctions then
      for k,v in pairs(template.privateFunctions) do
        inst[k] = v
      end
    end

    if template.publicFunctions then
      for k,v in pairs(template.publicFunctions) do
        inst[k] = v
        vis[k] = v
      end
    end

    return vis
  end

  return c
end
