lib/dry/events/bus.rb in dry-events-0.1.1 vs lib/dry/events/bus.rb in dry-events-0.2.0

- old
+ new

@@ -74,8 +74,21 @@ # @api private def subscribed?(listener) listeners.values.any? { |value| value.any? { |block, _| block.equal?(listener) } } end + + # @api private + def can_handle?(object_or_event_id) + case object_or_event_id + when String, Symbol + events.key?(object_or_event_id) + else + events + .values + .map(&:listener_method) + .any?(&object_or_event_id.method(:respond_to?)) + end + end end end end