class MyClass
extend Forwardable
def_delegators :@broker, :add
def subscribe_in_broker
@subscribers.map(&method(:add))
end
end
In this example @subscribers is a Hash and @broker.add takes two arguments: def broker(k,v).
This causes ArgumentError: wrong number of arguments (given 1, expected 2)
Is there a way to use Forwardable or a similar solution without this problem? How can I easily delegate an Array with 2 elements to a method which takes two arguments? What would be the equivalent of writing:
def subscribe_in_broker
@subscribers.map{|k,v| add(k,v) }
end
but using delegation?