<commit_before>require 'forwardable'
require 'ostruct'

require 'reform/composition'
require 'reform/representer'

require 'uber/inheritable_attr'


module Reform
  class Form
    extend Forwardable

    extend Uber::InheritableAttr
    inheritable_attr :representer_class
    self.representer_class = Class.new(Reform::Representer)


    module PropertyMethods
      extend Forwardable

      def property(name, options={}, &block)
        process_options(name, options, &block)

        # at this point, :extend is a Form class.
        definition = representer_class.property(name, options, &block)
        setup_form_definition(definition) if block_given? or options[:form]

        create_accessor(name)
      end

      def collection(name, options={}, &block)
        options[:form_collection] = options[:collection] =true

        property(name, options, &block)
      end

      def properties(names, *args)
        names.each { |name| property(name, *args) }
      end

      def setup_form_definition(definition)
        options = {
          :form         => definition[:form] || definition[:extend].evaluate(nil), # :form is always just a Form class name.
          :pass_options => true, # new style of passing args
          :prepare      => lambda { |form, args| form }, # always just return the form without decorating.
        }

        definition.merge!(options)
      end

    private
      def create_accessor(name)
        # Make a module that contains these very accessors, then include it
        # so they can be overridden but still are callable with super.
        accessors = Module.new do
          extend Forwardable # DISCUSS: do we really need Forwardable here?
          delegate [name, "#{name}="] => :fields
        end
        include accessors
      end<commit_msg>i said: remove all occurrences of :form_collection.<commit_after>require 'forwardable'
require 'ostruct'

require 'reform/composition'
require 'reform/representer'

require 'uber/inheritable_attr'


module Reform
  class Form
    extend Forwardable

    extend Uber::InheritableAttr
    inheritable_attr :representer_class
    self.representer_class = Class.new(Reform::Representer)


    module PropertyMethods
      extend Forwardable

      def property(name, options={}, &block)
        process_options(name, options, &block)

        # at this point, :extend is a Form class.
        definition = representer_class.property(name, options, &block)
        setup_form_definition(definition) if block_given? or options[:form]

        create_accessor(name)
      end

      def collection(name, options={}, &block)
        options[:collection] =true

        property(name, options, &block)
      end

      def properties(names, *args)
        names.each { |name| property(name, *args) }
      end

      def setup_form_definition(definition)
        options = {
          :form         => definition[:form] || definition[:extend].evaluate(nil), # :form is always just a Form class name.
          :pass_options => true, # new style of passing args
          :prepare      => lambda { |form, args| form }, # always just return the form without decorating.
        }

        definition.merge!(options)
      end

    private
      def create_accessor(name)
        # Make a module that contains these very accessors, then include it
        # so they can be overridden but still are callable with super.
        accessors = Module.new do
          extend Forwardable # DISCUSS: do we really need Forwardable here?
          delegate [name, "#{name}="] => :fields
        end
        include accessors
      end
{'fraction_non_alphanumeric': 0.08711283185840708, 'fraction_numerical': 0.0, 'mean_word_length': 2.698364008179959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4898505', 'n_tokens_mistral': 1002, 'n_tokens_neox': 943, 'n_words': 306}