<commit_before>module FoxySync::Xml
  #
  # Provides methods to easily query the transaction_detail
  # elements found in a FoxyCart transaction XML datafeed
  class TransactionDetail < Base

    #
    # Returns an +Array+ of +TransactionDetail+s from +transaction+
    # [_transaction_]
    #   A +FoxySync::Xml::Document+ that holds a transaction XML datafeed
    def self.all(transaction)
      transactions = []

      transaction.node.xpath('//transaction_details').each do |detail|
        transactions << new(detail)
      end

      transactions
    end


    #
    # Returns custom product options in a 'name' => 'value' +Hash+
    def custom_product_options
      options = {}
      options_xml = node.xpath '//transaction_detail_option'

      options_xml.each do |node|
        name = node.at_css('product_option_name').content.strip
        value = node.at_css('product_option_value').content.strip
        options[name] = value
      end

      options
    end

  end

end<commit_msg>update comment<commit_after>module FoxySync::Xml
  #
  # Provides methods to easily query the transaction_detail
  # elements found in a FoxyCart transaction XML datafeed
  class TransactionDetail < Base

    #
    # Returns an +Array+ of +TransactionDetail+s from +transaction_doc+
    # [_transaction_doc_]
    #   A +FoxySync::Xml::Document+ that has a transaction_details element
    def self.all(transaction_doc)
      transactions = []

      transaction_doc.node.xpath('//transaction_details').each do |detail|
        transactions << new(detail)
      end

      transactions
    end


    #
    # Returns custom product options in a 'name' => 'value' +Hash+
    def custom_product_options
      options = {}
      options_xml = node.xpath '//transaction_detail_option'

      options_xml.each do |node|
        name = node.at_css('product_option_name').content.strip
        value = node.at_css('product_option_value').content.strip
        options[name] = value
      end

      options
    end

  end

end
{'fraction_non_alphanumeric': 0.08838133068520357, 'fraction_numerical': 0.0, 'mean_word_length': 2.897485493230174, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4878114', 'n_tokens_mistral': 578, 'n_tokens_neox': 565, 'n_words': 151}