def foo(*args)
      h = (Hash === args.last ? args.pop : {})
      args.each{|m| h[m]=m}
      args = h 
      #....
  end

T.