<commit_before>module DaddysGirl
  module ActiveRecordModel
    class << self
      def symbol
        self.name.underscore.to_sym
      end

      def generate(attributes = {})
        FactoryGirl.create(self.symbol, attributes)
      end

      def generate!(attributes = {})
        FactoryGirl.create(self.symbol, attributes).tap do |obj|
          raise obj.errors.inspect unless obj.errors.empty?
        end
      end

      def spawn(attributes = {})
        FactoryGirl.build(self.symbol, attributes)
      end
    end
  end
end

ActiveRecord::Base.send(:include, DaddysGirl::ActiveRecordModel) if defined?(ActiveRecord)


module DaddysGirl
  module AssociationModel
    def target_class_symbol
      self.symbol
    end

    def generate(attributes = {})
      attributes = attributes.merge(association_attribute)
      FactoryGirl.create(target_class_symbol, attributes)
    end

    def generate!(attributes = {})
      attributes = attributes.merge(association_attribute)
      FactoryGirl.create(target_class_symbol, attributes).tap do |obj|
        raise obj.errors.inspect unless obj.errors.empty?
      end
    end

    def spawn(attributes = {})
      attributes = attributes.merge(association_attribute)
      FactoryGirl.build(target_class_symbol, attributes)
    end

    private
    def owner_association
      proxy_reflection.primary_key_name.to_sym
    end

    def association_attribute
      {owner_association => proxy_owner.id}
    end
  end
end

ActiveRecord::Associations::AssociationProxy.send(:include, DaddysGirl::AssocationModel) if defined?(ActiveRecord)
<commit_msg>Fixing association typo<commit_after>module DaddysGirl
  module ActiveRecordModel
    class << self
      def symbol
        self.name.underscore.to_sym
      end

      def generate(attributes = {})
        FactoryGirl.create(self.symbol, attributes)
      end

      def generate!(attributes = {})
        FactoryGirl.create(self.symbol, attributes).tap do |obj|
          raise obj.errors.inspect unless obj.errors.empty?
        end
      end

      def spawn(attributes = {})
        FactoryGirl.build(self.symbol, attributes)
      end
    end
  end
end

ActiveRecord::Base.send(:include, DaddysGirl::ActiveRecordModel) if defined?(ActiveRecord)


module DaddysGirl
  module AssociationModel
    def target_class_symbol
      self.symbol
    end

    def generate(attributes = {})
      attributes = attributes.merge(association_attribute)
      FactoryGirl.create(target_class_symbol, attributes)
    end

    def generate!(attributes = {})
      attributes = attributes.merge(association_attribute)
      FactoryGirl.create(target_class_symbol, attributes).tap do |obj|
        raise obj.errors.inspect unless obj.errors.empty?
      end
    end

    def spawn(attributes = {})
      attributes = attributes.merge(association_attribute)
      FactoryGirl.build(target_class_symbol, attributes)
    end

    private
    def owner_association
      proxy_reflection.primary_key_name.to_sym
    end

    def association_attribute
      {owner_association => proxy_owner.id}
    end
  end
end

ActiveRecord::Associations::AssociationProxy.send(:include, DaddysGirl::AssociationModel) if defined?(ActiveRecord)

{'fraction_non_alphanumeric': 0.08019894311470314, 'fraction_numerical': 0.0, 'mean_word_length': 3.1630012936610608, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6299451', 'n_tokens_mistral': 911, 'n_tokens_neox': 879, 'n_words': 184}