Method_missing

Using wisper, I wanted the listener to have a method_missing method.. to catch every broadcast. But wisper is using .respond_to? to check if the class have the method.

Enter respond_to_missing?. Force a true answer and everything is dandy.

require 'wisper'

class A_publisher
  include Wisper.publisher

  def bc(method, *args, **kw)
    broadcast(method.to_sym, *args, **kw)
  end
end

class Listener
  def method_missing(name, *args)
    p 'Method missing: (%s)' % name
  end

  def respond_to_missing?(name, ...) = true
end

# test
ap = A_publisher.new
ap.subscribe(Listener.new)

ap.bc(:one, [1,1,1], ok: true)
ap.bc(:two)
ap.bc(:three, 'blind mice')