Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csbase-dev
sgarest-daemon
Commits
a4f5c64c
Commit
a4f5c64c
authored
Mar 30, 2020
by
Carla Goncalves Ourofino
Browse files
Usa metatable para configuração default.
[SOMA-3827][SOMA-4135]
parent
bac7e381
Changes
1
Hide whitespace changes
Inline
Side-by-side
sga/configuration.lua
View file @
a4f5c64c
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment