<commit_before>module Reform
  class Form < Contract
    twin_representer_class.instance_eval do
      def default_inline_class
        Form
      end
    end

    require "reform/form/validate"
    include Validate # extend Contract#validate with additional behaviour.

    require "reform/form/populator"

    module Property
      # add macro logic, e.g. for :populator.
      def property(name, options={}, &block)
        if options.delete(:virtual)
          options[:writeable] = options[:readable] = false # DISCUSS: isn't that like an #option in Twin?
        end

        definition = super # let representable sort out inheriting of properties, and so on.
        definition.merge!(deserializer: {}) unless definition[:deserializer] # always keep :deserializer per property.


        deserializer_options = definition[:deserializer]

        # TODO: make this pluggable.<commit_msg>make :deserializer option hash Cloneable, so it gets cleanly copied in inherited contracts.<commit_after>module Reform
  class Form < Contract
    twin_representer_class.instance_eval do
      def default_inline_class
        Form
      end
    end

    require "reform/form/validate"
    include Validate # extend Contract#validate with additional behaviour.

    require "reform/form/populator"

    module Property
      # add macro logic, e.g. for :populator.
      def property(name, options={}, &block)
        if options.delete(:virtual)
          options[:writeable] = options[:readable] = false # DISCUSS: isn't that like an #option in Twin?
        end

        if deserializer = options[:deserializer] # this means someone is explicitly specifying :deserializer.
          options[:deserializer] = Representable::Cloneable::Hash[deserializer]
        end

        definition = super # let representable sort out inheriting of properties, and so on.
        definition.merge!(deserializer: Representable::Cloneable::Hash.new) unless definition[:deserializer] # always keep :deserializer per property.


        deserializer_options = definition[:deserializer]

        # TODO: make this pluggable.
{'fraction_non_alphanumeric': 0.07853403141361257, 'fraction_numerical': 0.0, 'mean_word_length': 3.1623762376237625, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4182084', 'n_tokens_mistral': 561, 'n_tokens_neox': 539, 'n_words': 175}