<commit_before>module Tenon
  module TenonContent
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def tenon_content(content_field, i18n: false)
        Tenon::TenonContentBuilder.add_assoc(self, content_field)

        define_method("#{content_field}_i18n?") { i18n }
        if i18n
          Tenon.config.languages.each do |title, lang|
            Tenon::TenonContentBuilder.add_assoc(self, "#{content_field}_#{lang}")
          end
        end
      end
    end
  end

  class TenonContentBuilder
    class << self
      def add_assoc(klass, content_field)
        assoc = "#{content_field}_tenon_content_rows".to_sym
        args = [assoc, -> { where(item_method: content_field) }, assoc_opts]
        klass.send(:has_many, *args)
        klass.send(:accepts_nested_attributes_for, assoc, allow_destroy: true)
      end

      private<commit_msg>Fix i18n Tenon Content call<commit_after>module Tenon
  module TenonContent
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def tenon_content(content_field, i18n: false)
        Tenon::TenonContentBuilder.add_assoc(self, content_field)

        define_method("#{content_field}_i18n?") { i18n }
        if i18n && Tenon.config.languages
          Tenon.config.languages.each do |title, lang|
            Tenon::TenonContentBuilder.add_assoc(self, "#{content_field}_#{lang}")
          end
        end
      end
    end
  end

  class TenonContentBuilder
    class << self
      def add_assoc(klass, content_field)
        assoc = "#{content_field}_tenon_content_rows".to_sym
        args = [assoc, -> { where(item_method: content_field) }, assoc_opts]
        klass.send(:has_many, *args)
        klass.send(:accepts_nested_attributes_for, assoc, allow_destroy: true)
      end

      private
{'fraction_non_alphanumeric': 0.09544468546637744, 'fraction_numerical': 0.009761388286334056, 'mean_word_length': 2.8842105263157896, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2730089', 'n_tokens_mistral': 601, 'n_tokens_neox': 591, 'n_words': 110}