mirror of
https://github.com/Insality/druid
synced 2025-09-27 10:02:19 +02:00
add factory.remove method
This commit is contained in:
@@ -81,6 +81,25 @@ local function create(module, factory)
|
||||
end
|
||||
|
||||
|
||||
function _factory.remove(factory, instance)
|
||||
for i = #factory, 1, -1 do
|
||||
if factory[i] == instance then
|
||||
table.remove(factory, i)
|
||||
end
|
||||
end
|
||||
local interest = instance.interest
|
||||
if interest then
|
||||
for i, v in ipairs(interest) do
|
||||
for j = #factory[v], 1, -1 do
|
||||
if factory[v][j] == instance then
|
||||
table.remove(factory[v], j)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function _factory.new(factory, module, ...)
|
||||
local instance = create(module, factory)
|
||||
|
||||
|
Reference in New Issue
Block a user