I'm using ruby 1.8.5 and I'd like to use a helper method to help filter a user's preferences like this:
def send_email(user, notification_method_name, *args)
# determine if the user wants this email
return if !user.send("wants_#{notification_method_name}?")
# different email methods have different argument lengths
Notification.send("deliver_#{notification_method_name}", user, *args)
end
This works in ruby 1.8.6, however when I try to do this in 1.8.5 and try to send more than one arg I get an error along the lines of:
wrong number of arguments (2 for X)
where X is the number of arguments that particular method requires. I'd rather not rewrite all my Notification methods - can Ruby 1.8.5 handle this?