Commit a4f5c64c authored by Carla Goncalves Ourofino's avatar Carla Goncalves Ourofino
Browse files

Usa metatable para configuração default.

parent bac7e381
......@@ -5,9 +5,11 @@ local safer = require("safer")
local schema = require("schema")
local util = require("sga.util")
local function get(config_data, filename, config)
local config = util.table_shallow_copy(config) or {}
config.sgas = nil -- avoid multiple inside multiple
local function get(config_data, filename, config_default)
local config = {}
config_default.sgas = nil -- avoid multiple inside multiple
config_default.__index = function (t,k) return config_default[k] end
setmetatable(config, config_default)
local chunk, err = load(config_data, filename, "t", config)
if not chunk then
return nil, "Failed loading config file "..filename..": "..err
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment