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: graceful_halt.rb
    path of file: ./repos/vagrant/lib/vagrant/action/builtin
    
    the code of the file until where you have to start completion: # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

require "log4r"
require "timeout"

module Vagrant
  module Action
    module Builtin
      # This middleware class will attempt to perform a graceful shutdown
      # of the machine using the guest implementation. This middleware is
      # compatible with the {Call} middleware so you can branch based on
      # the result, which is true if the halt succeeded and false otherwise.
      class GracefulHalt
 
    
        def call(env)
          graceful = true
          graceful = !env[:force_halt] if env.key?(:force_halt)

          # By default, we didn't succeed.
          env[:result] = false

          if graceful && @source_state
            @logger.info("Verifying source state of machine: #{@source_state.inspect}")

            # If we're not in the proper source state, then we don't
            # attempt to halt the machine
            current_state = env[:machine].state.id
            if current_state != @source_state
              @logger.info("Invalid source state, not halting: #{current_state}")
              graceful = false
            end
          end