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: body_edit.rb
    path of file: ./repos/htty/lib/htty/cli/commands
    
    the code of the file until where you have to start completion: require 'htty'
require 'tempfile'

# Encapsulates the _body
    
  def self.help_extended
    <<-EOH.gsub(/^(?: |\t)+/, '')
    Sets the body content used for the request. Does not communicate with
    the host.

    Uses the editor specified in EDITOR environment variable. Your editor will
    open with a temporary file, fill the file with the request body. When you
    are done save the file and quit the editor. The exact content of the
    temporary file will be used as the request body. The temporary file will be
    removed after this command.

    If you want to choose your editor, start htty with `EDITOR=vim htty`
    replacing 'vim' with your editor of choice.
    EOH
  end

  # Returns related command classes for the _body-edit_ command.
  def self.see_also_commands
    [ HTTY::CLI::Commands::BodyRequest,
      HTTY::CLI::Commands::BodyUnset,
      HTTY::CLI::Commands::BodySet
    ]
  end

  # Performs the _body-edit_ command.
  def perform
    add_request_if_new do |request|
      request.body_set(with_editor do |editor|
        file = Tempfile.new('htty')
        if last_request_body = session.requests.last.body
          File.open(file.path, 'w+') {|f| f.write(last_request_body)}
        end
        result = system(editor + ' ' + file.path)
        if not result
          return empty_body_because("Unable to use '#{editor}' to edit request's body")
        end
        body = File.read(file.path)
        file.unlink
        body
      end)
    end
  end