I want to use an options hash as input to a method in Ruby, but is there a way to quickly set all eponymous variables (i.e having the same name) instead of setting each individually?
So instead of doing the following:
class Connection
def initialize(opts={})
@host = opts[:host]
@user = opts[:user]
@password = opts[:password]
@project = opts[:project]
# ad nauseum...
is there a one-liner that will assign each incoming option in the hash to the variable with the same name?