<commit_before>module PropertySets
  module Delegator
    # methods for moving what was once a literal column on
    # to a property_set table.
    #
    # delegates read, write and query methods to the property record or the property default
    #
    # Examples
    #
    #   # Migrate :is_open to the :settings property set, and rename it :open,
    #   # and migrate :same to property set :same
    #   include PropertySets::Delegator
    #   delegate_to_property_set :settings, :is_open => :open, :same => :same
    #
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def delegate_to_property_set(setname, mappings)
        raise "Second argument must be a Hash" unless mappings.is_a?(Hash)

        @delegated_property_set_attributes ||= []

        mappings.each do |old_attr, new_attr|
          self.delegated_property_set_attributes << old_attr.to_s
          if ActiveRecord.version < Gem::Version.new("5.0")
            attribute old_attr, ActiveRecord::Type::Value.new
          else
            attribute old_attr, ActiveModel::Type::Value.new
          end
          define_method(old_attr) {
            association = send(setname)
            type = association.klass.type(new_attr)<commit_msg>Switch to method defined by AssociationExtensions<commit_after>module PropertySets
  module Delegator
    # methods for moving what was once a literal column on
    # to a property_set table.
    #
    # delegates read, write and query methods to the property record or the property default
    #
    # Examples
    #
    #   # Migrate :is_open to the :settings property set, and rename it :open,
    #   # and migrate :same to property set :same
    #   include PropertySets::Delegator
    #   delegate_to_property_set :settings, :is_open => :open, :same => :same
    #
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def delegate_to_property_set(setname, mappings)
        raise "Second argument must be a Hash" unless mappings.is_a?(Hash)

        @delegated_property_set_attributes ||= []

        mappings.each do |old_attr, new_attr|
          self.delegated_property_set_attributes << old_attr.to_s
          if ActiveRecord.version < Gem::Version.new("5.0")
            attribute old_attr, ActiveRecord::Type::Value.new
          else
            attribute old_attr, ActiveModel::Type::Value.new
          end
          define_method(old_attr) {
            association = send(setname)
            type = association.association_class.type(new_attr)
{'fraction_non_alphanumeric': 0.07866043613707165, 'fraction_numerical': 0.001557632398753894, 'mean_word_length': 2.71242774566474, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '7033894', 'n_tokens_mistral': 730, 'n_tokens_neox': 717, 'n_words': 204}