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: package.rb
    path of file: ./repos/openfoodnetwork/engines/order_management/app/services/order_management/stock
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module OrderManagement
  module Stock
    class Package
      ContentItem = Struct.new(:variant, :quantity, :state)

      attr_reader :stock_location, :order, :contents
      attr_accessor :shipping_rates

      def initialize(stock_location, order, contents = [])
        @stock_
    
      def find_item(variant, state = :on_hand)
        contents.select do |item|
          item.variant == variant &&
            item.state == state
        end.first
      end

      def quantity(state = nil)
        case state
        when :on_hand
          on_hand.sum(&:quantity)
        when :backordered
          backordered.sum(&:quantity)
        else
          contents.sum(&:quantity)
        end
      end