<commit_before>require "transproc"
require "formalist/rich_text/embedded_form_compiler"

module Formalist
  module RichText

    # - Need to initialize this with the embedded form collection
    # - And then call it with the hash of the form post data
    #
    # I also need to supply a custom transformer, kind of like map_values
    #
    # Usage? Something like this:
    #
    # class MyFormTransformer < Formalist::RichText::Transformer[MyEmbeddedForms]
    #   prepare_rich_text :body
    # end

    class Transformer < Transproc::Transformer
      Undefined = Object.new.freeze

      class << self
        def [](embedded_form_collection)
          Class.new(self).tap do |klass|
            klass.embedded_form_collection embedded_form_collection
          end
        end

        def embedded_form_collection(collection = Undefined)
          if collection == Undefined
            @embedded_form_collection
          else
            @embedded_form_collection = collection
          end
        end<commit_msg>Update transformer<commit_after>require "transproc"
require "formalist/rich_text/embedded_form_compiler"

module Formalist
  module RichText
    def self.Transformer(embedded_form_collection, &block)
      Transformer.define(embedded_form_collection, &block)
    end

    class Transformer < Transproc::Transformer
      class << self
        attr_reader :embedded_form_collection

        def define(embedded_form_collection, &block)
          Class.new(self).tap do |klass|
            klass.instance_variable_set :@embedded_form_collection, embedded_form_collection
            klass.instance_exec(&block)
          end.new
        end
{'fraction_non_alphanumeric': 0.062010836845273934, 'fraction_numerical': 0.0, 'mean_word_length': 2.8561484918793503, 'pattern_counts': {'":': 0, '<': 10, '<?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': '3816932', 'n_tokens_mistral': 460, 'n_tokens_neox': 439, 'n_words': 112}