You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: _urlsafe_serialization.rb
    path of file: ./repos/shrine/lib/shrine/plugins
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require "base64"
require "json"

class Shrine
  module Plugins
    # This is an internal plugin used by download_endpoint and
    # derivation_endpoint plugins.
    module UrlsafeSerialization
      module ClassMethods
        def urlsaf
    
        def urlsafe_data(metadata: [])
          data = self.data.dup

          if metadata.any?
            # order metadata in the specified order
            data["metadata"] = metadata
              .map { |name| [name, self.metadata[name]] }
              .to_h
          else
            # save precious characters
            data.delete("metadata")
          end