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: filesystem_steps.rb
    path of file: ./repos/activeadmin/features/step_definitions
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
module ActiveAdminContentsRollb
    
  def rollback_file(file, contents)
    if contents.present?
      File.open(file, "w") { |f| f << contents }
    else
      File.delete(file)
      begin
        dir = File.dirname(file)
        until dir == Rails.root
          Dir.rmdir(dir) # delete current folder
          dir = dir.split("/")[0..-2].join("/") # select parent folder
        end