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: validation_state_guard.rb
    path of file: ./repos/sequencescape/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
# It's such a common pattern in the code to have a guard on some our validations that this module provides
# that facility.  You can declare a guard with:
#
#     extend ValidationStateGuard
#     validation_guard(:guard_name)
#
# This then gives you *private* methods of guard_name, guard_name=, and guard_name?  It also add
    
  def validation_guarded_by(method, guard) # rubocop:todo Metrics/MethodLength
    # Method name could end in ! or ?, in which case the unguarded name needs to be correct.
    method.to_s =~ /^([^!?]+)([!?])?$/
    core_name, extender = $1, $2
    unguarded_name = :"#{core_name}_unguarded_by_#{guard}#{extender}"

    line = __LINE__ + 1
    class_eval(
      "
      alias_method(#{unguarded_name.inspect}, #{method.to_sym.inspect})
      def #{method}(*args, &block)
        send(#{guard.to_sym.inspect}=, true)
        #{unguarded_name}(*args, &block)
      ensure
        send(#{guard.to_sym.inspect}=, false)
      end
    ",
      __FILE__,
      line
    )
  end