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: lock.rb
    path of file: ./repos/expertiza/app/models
    
    the code of the file until where you have to start completion: # This class was added to facilitate functionality in E1973:
# http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2019_-_Project_E1973._Team_Based_Reviewing
# But was generalized at th
    
  def self.get_lock(lockable, user, timeout)
    return nil if lockable.nil? || user.nil?

    lock = find_by(lockable: lockable)
    return create_lock(lockable, user, timeout) if lock.nil?

    # We need to put an actual database lock on this object to prevent concurrent acquisition of this object
    # If two users were to request a lock at the same time, they might otherwise be able to acquire this lock simultaneously
    lock.with_lock do
      # If the timeout period is up, the lock is fair game
      if lock.created_at + lock.timeout_period.minutes <= DateTime.now
        lock.destroy
        return create_lock(lockable, user, timeout)
      end
      # Your last chance on acquiring the lock is if you already own it
      if lock.user_id == user.id
        lock.destroy
        return create_lock(lockable, user, timeout)
      end