How can I dynamically call a method in a module?
module Notification
def self.send_notification(title, message)
puts title + message
end
end
def test(string)
p string
end
if __FILE__ == $0
send("test", 'hello from test')
send("Notification.send_notification", 'hello', 'there') # Error: undefined method `Notification.send' for main:Object (NoMethodError)
end
Edit: I have more than one Module in my library and I really need to be able to convert a string to the module name. Say I also have a Module called Email. Maybe Eval is the only way? Edit2: Renamed method in order not to conflict with built in send-method.