From f669498c696c69b9a738008f760161a2237b2771 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 3 Aug 2023 14:15:46 +0100 Subject: [PATCH] remove_observers now accepts array of callbacks callbacks aliases observers patch bump --- lib/obsws/event.rb | 6 ++++-- lib/obsws/version.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/obsws/event.rb b/lib/obsws/event.rb index d618c0e..ff6ec3c 100644 --- a/lib/obsws/event.rb +++ b/lib/obsws/event.rb @@ -47,10 +47,11 @@ module OBSWS end def remove_observer(observer) - observers.delete(observer) + observer = [observer] unless observer.respond_to? :each + observers.reject! { |o| observer.include? o } end - def notify_observers(event, data) + private def notify_observers(event, data) observers.each do |o| if o.is_a? Method if o.name.to_s == "on_#{snakecase(event)}" @@ -62,6 +63,7 @@ module OBSWS end end + alias_method :callbacks, :observers alias_method :register, :add_observer alias_method :deregister, :remove_observer end diff --git a/lib/obsws/version.rb b/lib/obsws/version.rb index f18562b..1f22c0d 100644 --- a/lib/obsws/version.rb +++ b/lib/obsws/version.rb @@ -11,7 +11,7 @@ module OBSWS end def patch - 0 + 1 end def to_a