<commit_before>Spree::LineItem.class_eval do
  
  has_many :digital_links, :dependent => :destroy
  after_save :create_digital_links, :if => :digital?
  
  def digital?
    variant.digital?
  end
  
  private
  
  # Create the download link for this item if it is digital.
  def create_digital_links
    digital_links.delete_all

    variant.digitals.each do |digital|
      self.quantity.times do
        digital_links.create!(:digital => digital)
      end      
    end
  end
  
end
<commit_msg>Note about improvement to create_digital_links<commit_after>Spree::LineItem.class_eval do
  
  has_many :digital_links, :dependent => :destroy
  after_save :create_digital_links, :if => :digital?
  
  def digital?
    variant.digital?
  end
  
  private
  
  # TODO there is no reason to create the digital links until the order is complete
  def create_digital_links
    digital_links.delete_all

    variant.digitals.each do |digital|
      self.quantity.times do
        digital_links.create!(:digital => digital)
      end      
    end
  end
  
end

{'fraction_non_alphanumeric': 0.07129277566539924, 'fraction_numerical': 0.0, 'mean_word_length': 3.019083969465649, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5093598', 'n_tokens_mistral': 343, 'n_tokens_neox': 323, 'n_words': 88}