Sha256: 696de1d6cdb3f7e4af78c2985c5322db2edd76e14361c0048b12a9944f9c21ff

Contents?: true

Size: 750 Bytes

Versions: 16

Compression:

Stored size: 750 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)
        super unless recipients

        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) } || super(name, include_private)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
cucumber-9.2.1 lib/cucumber/formatter/fanout.rb
cucumber-9.2.0 lib/cucumber/formatter/fanout.rb
cucumber-9.1.2 lib/cucumber/formatter/fanout.rb
cucumber-9.1.1 lib/cucumber/formatter/fanout.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.1.0/lib/cucumber/formatter/fanout.rb
cucumber-9.1.0 lib/cucumber/formatter/fanout.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.0.2/lib/cucumber/formatter/fanout.rb
cucumber-9.0.2 lib/cucumber/formatter/fanout.rb
cucumber-9.0.1 lib/cucumber/formatter/fanout.rb
cucumber-9.0.0 lib/cucumber/formatter/fanout.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/fanout.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/fanout.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/fanout.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/fanout.rb
cucumber-8.0.0 lib/cucumber/formatter/fanout.rb
cucumber-8.0.0.rc.1 lib/cucumber/formatter/fanout.rb