motion/core/kvo.rb in bubble-wrap-1.7.0 vs motion/core/kvo.rb in bubble-wrap-1.7.1

- old
+ new

@@ -51,11 +51,11 @@ return if @targets.nil? @targets.each do |target, key_paths| key_paths.each_key do |key_path| target.removeObserver(self, forKeyPath:key_path) - end + end end remove_all_observer_blocks end # Observer blocks @@ -79,9 +79,12 @@ def remove_observer_block(target, key_path) return if @targets.nil? || target.nil? || key_path.nil? key_paths = @targets[target] key_paths.delete(key_path.to_s) if !key_paths.nil? + if key_paths.nil? || key_paths.length == 0 + @targets.delete(target) + end end def remove_all_observer_blocks @targets.clear unless @targets.nil? end