I would like the opinions of my friends and frenemies wherever they exist! This is how I implement Open/Closed: Open/Closed in Ruby All points of view are fair game. You can even tell me I am stupid. I can handle any conversation you want to throw at me!
module NewsDigestBroadcaster
def broadcast(user, broadcaster)
broadcaster.(user, news_digest)
end
end
This is IMO cleaner and simpler. It’s also easier to test. There’s no way to inject a dummy broadcaster into your code without creating a global constant (which isn’t side-effect free and might causes problems on consecutive test runs).
Also: Why do you use modules instead of classes? Modules already serve two purposes (namespaces and traits).