Sha256: 35c805a219673687fdc3206fc0c8e7a85ffed926bab9d980d6ef906030d5c6ef

Contents?: true

Size: 685 Bytes

Versions: 4

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

module Cucumber
  module Formatter
    # Forwards any messages sent to this object to all recipients
    # that respond to that message.
    class Fanout < BasicObject
      attr_reader :recipients
      private :recipients

      def initialize(recipients)
        @recipients = recipients
      end

      def method_missing(message, *args)
        recipients.each do |recipient|
          recipient.send(message, *args) if recipient.respond_to?(message)
        end
      end

      def respond_to_missing?(name, include_private = false)
        recipients.any? { |recipient| recipient.respond_to?(name, include_private) }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
cucumber-3.2.0 lib/cucumber/formatter/fanout.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/cucumber-3.1.2/lib/cucumber/formatter/fanout.rb
cucumber-3.1.2 lib/cucumber/formatter/fanout.rb
cucumber-3.1.1 lib/cucumber/formatter/fanout.rb