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: lending.rb
    path of file: ./repos/circulate/app/controllers/concerns
    
    the code of the file until where you have to start completion: module Lending
  private

  def create_loan(item, member, now: Time.current)
    loan = Loan.lend(item, to: member, now: now)
    loan.transaction do
      if loan.save && item.borrow_policy.consumable? && return_loan(loan, now: now)
        item.decrement_quantity
      end
      loan
    end
  end

  def create_loan_from_hold(hold, now: Time.current)
    hold.transaction do
      create_loan(hold.item, hold.member, now: now).tap do |loan|
        hold.update!(loan: loan, ended_at: now)
      end
    end
  end

  def return_loan(loan, now: Time.current)
    succes
    
  def renew_loan(loan, now: Time.current)
    success = false
    period_start_date = [loan.due_at, now.end_of_day].max
    new_loan = Loan.new(
      member_id: loan.member_id,
      item_id: loan.item_id,
      initial_loan_id: loan.initial_loan_id || loan.id,
      renewal_count: loan.renewal_count + 1,
      due_at: Loan.next_open_day(period_start_date + loan.item.borrow_policy.duration.days),
      uniquely_numbered: loan.uniquely_numbered,
      created_at: now
    )

    loan.transaction do
      next unless return_loan(loan, now: now)
      new_loan.save!

      # update any appointments connected with the old loan
      AppointmentLoan.where(loan_id: loan).update_all(loan_id: new_loan.id)

      success = true
    end

    success ? new_loan : false
  end