File tree 2 files changed +23
-13
lines changed
2 files changed +23
-13
lines changed Original file line number Diff line number Diff line change 883
883
}
884
884
_base_0 .__index = _base_0
885
885
_class_0 = setmetatable ({
886
- __init = function (self , config )
887
- if config == nil then
888
- config = { }
889
- end
890
- self .config = config
891
- assert (not getmetatable (self .config ), " options argument must not have a metatable to allow default configuration to be inherited" )
892
- setmetatable (self .config , {
893
- __index = self .default_config
886
+ __init = function (self , _config )
887
+ if _config == nil then
888
+ _config = { }
889
+ end
890
+ self ._config = _config
891
+ self .config = setmetatable ({ }, {
892
+ __index = function (t , key )
893
+ local value = self ._config [key ]
894
+ if value == nil then
895
+ return self .default_config [key ]
896
+ else
897
+ return value
898
+ end
899
+ end
894
900
})
895
901
self .sock , self .sock_type = socket .new (self .config .socket_type )
896
902
end ,
Original file line number Diff line number Diff line change @@ -171,11 +171,15 @@ class Postgres
171
171
-- ssl_verify: verify the certificate
172
172
-- cqueues_openssl_context: manually created openssl.ssl.context for cqueues sockets
173
173
-- luasec_opts: manually created options for LuaSocket ssl connections
174
- new : ( @config = {} ) =>
175
- assert not getmetatable ( @config ) ,
176
- " options argument must not have a metatable to allow default configuration to be inherited"
177
-
178
- setmetatable @config , __index : @default_config
174
+ new : ( @_config = {} ) =>
175
+ @config = setmetatable {} , {
176
+ __index : ( t, key) ->
177
+ value = @_config [ key]
178
+ if value == nil
179
+ @default_config [ key]
180
+ else
181
+ value
182
+ }
179
183
180
184
@sock , @sock_type = socket. new @config . socket_type
181
185
You can’t perform that action at this time.
0 commit comments