<commit_before>require 'hashie/extensions/ignore_undeclared'

module Trax
  module Model
    module Attributes
      module Types
        class String < ::Trax::Model::Attributes::Type
          def self.define_attribute(klass, attribute_name, **options, &block)
            attributes_klass = klass.fields_module.const_set(attribute_name.to_s.camelize, ::Class.new(value_klass))
            attributes_klass.instance_eval(&block) if block_given?
            klass.attribute(attribute_name, typecaster_klass.new(target_klass: attributes_klass))
            klass.validates(attribute_name, options[:validates]) if options.key?(:validate)

            klass.default_value_for(attribute_name) { options[:default] } if options.key?(:default)
          end

          class Value < ::Trax::Model::Attributes::Value
            def self.type; :string end;
          end

          class TypeCaster < ActiveRecord::Type::String
            def initialize(*args, target_klass:)
              super(*args)

              @target_klass = target_klass<commit_msg>use named class for string<commit_after>require 'hashie/extensions/ignore_undeclared'

module Trax
  module Model
    module Attributes
      module Types
        class String < ::Trax::Model::Attributes::Type
          def self.define_attribute(klass, attribute_name, **options, &block)
            klass_name = "#{klass.fields_module.name.underscore}/#{attribute_name.to_s}".camelize
            attribute_klass = if options.key?(:class_name)
              options[:class_name].constantize
            else
              ::Trax::Core::NamedClass.new(klass_name, Value, :parent_definition => klass, &block)
            end

            klass.attribute(attribute_name, typecaster_klass.new(target_klass: attributes_klass))
            klass.validates(attribute_name, options[:validates]) if options.key?(:validate)
            klass.default_value_for(attribute_name) { options[:default] } if options.key?(:default)
          end

          class Value < ::Trax::Model::Attributes::Value
            def self.type; :string end;
          end

          class TypeCaster < ActiveRecord::Type::String
            def initialize(*args, target_klass:)
              super(*args)

              @target_klass = target_klass
{'fraction_non_alphanumeric': 0.10180696342000882, 'fraction_numerical': 0.0, 'mean_word_length': 2.8279932546374367, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 4, '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': '4926899', 'n_tokens_mistral': 610, 'n_tokens_neox': 625, 'n_words': 116}