module Xapi
  module Helpers
    module Guards
      def require_key
        unless params[:key]
          halt 401, {error: "Please provide your Exercism.io API key"}.to_json
        end
      end
    end
  end
end

module Xapi
  module Helpers
    module Guards
      def require_key
        return if params[:key]

        halt 401, {error: "Please provide your Exercism.io API key"}.to_json
      end
    end
  end
end

Simplify to use guard in route helper
Simplify to use guard in route helper
