<commit_before>module ObjectiveForm
  class Base
    extend ActiveModel::Naming
    include ActiveModel::Conversion
    include ActiveModel::Validations
    class_attribute :pseudo_relations, :attributes

    def initialize(attributes = {})
      attributes.each do |name, value|
        send("#{name}=", value)
      end

      pseudo_relations.each do |rel|
        instance_variable_set("@#{rel.name}", []) unless send(rel.name)
      end
    end

    def persisted?
      false
    end

    def save
      if valid?
        persist!
        true
      else
        false
      end
    end

    def persist!
      raise NotImplementedError
    end

    private

    def initialize_attribute_value(klass_or_proc, value)
      return value.to_s if klass_or_proc == String

      if klass_or_proc == Array
        return [] if value.blank?
        return Array.wrap(value)
      end<commit_msg>pseudo_relations appear only if has_many is defined<commit_after>module ObjectiveForm
  class Base
    extend ActiveModel::Naming
    include ActiveModel::Conversion
    include ActiveModel::Validations
    class_attribute :pseudo_relations, :attributes

    def initialize(attributes = {})
      attributes.each do |name, value|
        send("#{name}=", value)
      end

      unless pseudo_relations.nil?
        pseudo_relations.each do |rel|
          instance_variable_set("@#{rel.name}", []) unless send(rel.name)
        end
      end
    end

    def persisted?
      false
    end

    def save
      if valid?
        persist!
        true
      else
        false
      end
    end

    def persist!
      raise NotImplementedError
    end

    private

    def initialize_attribute_value(klass_or_proc, value)
      return value.to_s if klass_or_proc == String

      if klass_or_proc == Array
        return [] if value.blank?
        return Array.wrap(value)
      end
{'fraction_non_alphanumeric': 0.07245604688332445, 'fraction_numerical': 0.0, 'mean_word_length': 2.266086956521739, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5154289', 'n_tokens_mistral': 544, 'n_tokens_neox': 529, 'n_words': 142}