Skip to content

Commit

Permalink
style(dynamic_hook): rename the third argument of function `hook_func…
Browse files Browse the repository at this point in the history
…tion` from `child_key` to `function_key` for readability

Co-authored-by: samugi <[email protected]>
  • Loading branch information
ADD-SP and samugi committed May 27, 2024
1 parent ef95c2b commit 6c69e24
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kong/dynamic_hook/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,24 @@ local function wrap_function(max_args, group_name, original_func, handlers)
end


function _M.hook_function(group_name, parent, child_key, max_args, handlers)
function _M.hook_function(group_name, parent, function_key, max_args, handlers)
assert(type(group_name) == "string", "group_name must be a string")
assert(type(parent) == "table", "parent must be a table")
assert(type(child_key) == "string", "child_key must be a string")
assert(type(function_key) == "string", "function_key must be a string")

local is_varargs = max_args == "varargs"
if not is_varargs then
assert(type(max_args) == "number", 'max_args must be a number or "varargs"')
assert(max_args >= 0 and max_args <= 8, 'max_args must be >= 0 and <= 8, or "varargs"')
end

local original_func = parent[child_key]
assert(type(original_func) == "function", "parent[" .. child_key .. "] must be a function")
local original_func = parent[function_key]
assert(type(original_func) == "function", "parent[" .. function_key .. "] must be a function")

if is_varargs then
parent[child_key] = wrap_function_vararg(group_name, original_func, handlers)
parent[function_key] = wrap_function_vararg(group_name, original_func, handlers)
else
parent[child_key] = wrap_function(max_args, group_name, original_func, handlers)
parent[function_key] = wrap_function(max_args, group_name, original_func, handlers)
end
end

Expand Down

0 comments on commit 6c69e24

Please sign in to comment.