use Kernel#Array in register,deregister

This commit is contained in:
onyx-and-iris 2023-08-29 15:32:23 +01:00
parent a3523eeb40
commit 5307bebea8

View File

@ -10,12 +10,12 @@ module Voicemeeter
end
def register(cbs)
cbs = [cbs] unless cbs.respond_to? :each
cbs = Array(cbs) unless cbs.respond_to? :each
cbs.each { |cb| on(cb.name[3..].to_sym, cb) }
end
def deregister(cbs)
cbs = [cbs] unless cbs.respond_to? :each
cbs = Array(cbs) unless cbs.respond_to? :each
cbs.each { |cb| observers[cb.name[3..].to_sym]&.reject! { |o| cbs.include? o } }
end