lib/dry/events/bus.rb in dry-events-0.3.0 vs lib/dry/events/bus.rb in dry-events-0.4.0
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'dry/events/constants'
+require "dry/events/constants"
module Dry
module Events
# Event bus
#
@@ -74,10 +74,17 @@
self
end
# @api private
def subscribed?(listener)
- listeners.values.any? { |value| value.any? { |block, _| block.equal?(listener) } }
+ listeners.values.any? do |value|
+ value.any? do |block, _|
+ case listener
+ when Proc then block.equal?(listener)
+ when Method then listener.owner == block.owner && listener.name == block.name
+ end
+ end
+ end
end
# @api private
def can_handle?(object_or_event_id)
case object_or_event_id