Sha256: 355a8fe96f5b1d144bcbbcc7c733625e466dc78ef842d5786dea686463fbb5c5

Contents?: true

Size: 687 Bytes

Versions: 6

Compression:

Stored size: 687 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

6 entries across 6 versions & 1 rubygems

Version Path
cucumber-3.1.0 lib/cucumber/formatter/fanout.rb
cucumber-3.0.2 lib/cucumber/formatter/fanout.rb
cucumber-3.0.1 lib/cucumber/formatter/fanout.rb
cucumber-3.0.0 lib/cucumber/formatter/fanout.rb
cucumber-3.0.0.pre.2 lib/cucumber/formatter/fanout.rb
cucumber-3.0.0.pre.1 lib/cucumber/formatter/fanout.rb