You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fanout.rb 750 B

2 years ago
12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. module Cucumber
  3. module Formatter
  4. # Forwards any messages sent to this object to all recipients
  5. # that respond to that message.
  6. class Fanout < BasicObject
  7. attr_reader :recipients
  8. private :recipients
  9. def initialize(recipients)
  10. @recipients = recipients
  11. end
  12. def method_missing(message, *args)
  13. super unless recipients
  14. recipients.each do |recipient|
  15. recipient.send(message, *args) if recipient.respond_to?(message)
  16. end
  17. end
  18. def respond_to_missing?(name, include_private = false)
  19. recipients.any? { |recipient| recipient.respond_to?(name, include_private) } || super(name, include_private)
  20. end
  21. end
  22. end
  23. end

No Description

Contributors (1)