Class: Cucumber::Formatter::Fanout

Inherits:
BasicObject
Defined in:
lib/cucumber/formatter/fanout.rb

Overview

Forwards any messages sent to this object to all recipients that respond to that message.

Instance Method Summary collapse

Constructor Details

#initialize(recipients) ⇒ Fanout

Returns a new instance of Fanout.



11
12
13
# File 'lib/cucumber/formatter/fanout.rb', line 11

def initialize(recipients)
  @recipients = recipients
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(message, *args) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/cucumber/formatter/fanout.rb', line 15

def method_missing(message, *args)
  super unless recipients

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

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cucumber/formatter/fanout.rb', line 23

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