<commit_before># frozen_string_literal: true

module CsvRecord::Writer
  module ClassMethods
    def __create__(attributes={})
      instance = build attributes
      yield instance if block_given?
      instance.save
      instance
    end

    [:attr_accessor, :attr_writer].each do |custom_accessor|
      define_method custom_accessor do |*attributes|
        attributes.each do |attribute|
          unless fields.has_name? attribute
            fields << CsvRecord::Field.new(attribute)
          end
        end
        super(*attributes)
      end
    end

    def store_as(name)
      @table_name = name.to_s.underscore.pluralize
      redefine_database_location

      @table_name
    end

    def table_name
      @table_name ||= store_as name
    end

    def mapping(config=[])<commit_msg>Using Object#tap instead of temporary variables on CsvRecord::Writer#create<commit_after># frozen_string_literal: true

module CsvRecord::Writer
  module ClassMethods
    def __create__(attributes={})
      build(attributes).tap do |instance|
        yield instance if block_given?
        instance.save
      end
    end

    [:attr_accessor, :attr_writer].each do |custom_accessor|
      define_method custom_accessor do |*attributes|
        attributes.each do |attribute|
          unless fields.has_name? attribute
            fields << CsvRecord::Field.new(attribute)
          end
        end
        super(*attributes)
      end
    end

    def store_as(name)
      @table_name = name.to_s.underscore.pluralize
      redefine_database_location

      @table_name
    end

    def table_name
      @table_name ||= store_as name
    end

    def mapping(config=[])
{'fraction_non_alphanumeric': 0.07411835026897788, 'fraction_numerical': 0.0, 'mean_word_length': 2.6077586206896552, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2453219', 'n_tokens_mistral': 487, 'n_tokens_neox': 470, 'n_words': 116}