<commit_before>require "pseudo_model/version"

module PseudoModel
  class Base
    include ActiveModel::Validations
    include ActiveModel::Conversion

    def initialize(attributes = {})
      raise TypeError, '`attributes` must be a Hash or respond to :to_hash or :to_h' unless attributes.is_a?(Hash) || attributes.respond_to?(:to_hash) || attributes.respond_to?(:to_h)
      attributes = attributes.to_hash rescue attributes.to_h unless attributes.is_a?(Hash)
      
      attributes.each do |name, value|
        send("#{name}=", value)
      end
    end

    def persisted?
      false
    end
  end
end
<commit_msg>Add validation callbacks.<commit_after>require "pseudo_model/version"

module PseudoModel
  class Base
    include ActiveModel::Validations
    include ActiveModel::Validations::Callbacks
    include ActiveModel::Conversion

    def initialize(attributes = {})
      raise TypeError, '`attributes` must be a Hash or respond to :to_hash or :to_h' unless attributes.is_a?(Hash) || attributes.respond_to?(:to_hash) || attributes.respond_to?(:to_h)
      attributes = attributes.to_hash rescue attributes.to_h unless attributes.is_a?(Hash)
      
      attributes.each do |name, value|
        send("#{name}=", value)
      end
    end

    def persisted?
      false
    end
  end
end

{'fraction_non_alphanumeric': 0.09739263803680982, 'fraction_numerical': 0.0, 'mean_word_length': 3.562937062937063, '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': '3994512', 'n_tokens_mistral': 385, 'n_tokens_neox': 384, 'n_words': 102}