mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
add factory.remove method
This commit is contained in:
parent
08eae3800c
commit
205253c98d
@ -81,6 +81,25 @@ local function create(module, factory)
|
|||||||
end
|
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, ...)
|
function _factory.new(factory, module, ...)
|
||||||
local instance = create(module, factory)
|
local instance = create(module, factory)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user