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: router.rb
    path of file: ./repos/sinatra-rest-api/lib/sinatra-rest-api
    
    the code of the file until where you have to start completion: module Sinatra
  module RestApi
    # Router
    class Router
      EXTS = [ 'json' ].freeze # TODO: load valid exts from an option
      VERBS = [ :get, :post, :put, :patch, :delete, :options, :link, :unlink ].freeze

      attr_reader :path_singular, :plural

      @@all_routes = []

      def initialize( provider )
        @provider = provider
        options = @provider.options
        @path_singular = options[:singular].nil? ? provid
    
      def prepare_route( route_args )
        if VERBS.include? route_args[:verb]
          @@all_routes.push "#{route_args[:verb].upcase}: #{route_args[:path]}"
          @provider.app.send( route_args[:verb], route_args[:path] ) do
            # app = self
            begin
              raise( APIError, 'Invalid request format' ) if !params[:format].nil? && !EXTS.include?( params[:format] )
              route_args[:request] = request
              route_args[:response] = response
              if Actions.respond_to? route_args[:route]
                Actions.send( route_args[:route], route_args, params, route_args[:mapping] )
              else
                params[:_action] = route_args[:route]
                Actions.other( route_args, params, route_args[:mapping] )
              end
            rescue StandardError => e
              Router.on_error e
            end