<commit_before>require "sequel/mapper/version"
require "sequel/mapper/struct"
require 'sequel/core'
require 'forwardable'

module Sequel
  module Mapper
    extend Forwardable

    def initialize(options)
      if options.is_a? Sequel::Dataset
        @db = options.db
        @dataset = options.clone
      elsif options.is_a? Sequel::Database
        @db = options
        raise ArgumentError, 'no dataset defined' if self.class._dataset.nil?
        @dataset = db[self.class._dataset]
      else
        raise ArgumentError, 'no database or dataset'
      end
      @dataset.row_proc = method(:data_to_object)
      @model = self.class._model || Sequel::Mapper::Struct.new(*dataset.columns)
      @primary_key = self.class._primary_key || :id
    end

    attr_reader :dataset

    def create(object)
      id = dataset.insert object_to_data(object)
      object.send("#{primary_key}=", id) unless object.public_send(primary_key)
    end

    def find(key)
      find_object(key: key).first
    end
    alias :[] :find

    def update(object)<commit_msg>Fix use of deprecated method (#2)<commit_after>require "sequel/mapper/version"
require "sequel/mapper/struct"
require 'sequel/core'
require 'forwardable'

module Sequel
  module Mapper
    extend Forwardable

    def initialize(options)
      if options.is_a? Sequel::Dataset
        @db = options.db
        ds = options
      elsif options.is_a? Sequel::Database
        @db = options
        raise ArgumentError, 'no dataset defined' if self.class._dataset.nil?
        ds = db[self.class._dataset]
      else
        raise ArgumentError, 'no database or dataset'
      end
      @dataset = ds.with_row_proc method(:data_to_object)
      @model = self.class._model || Sequel::Mapper::Struct.new(*dataset.columns)
      @primary_key = self.class._primary_key || :id
    end

    attr_reader :dataset

    def create(object)
      id = dataset.insert object_to_data(object)
      object.send("#{primary_key}=", id) unless object.public_send(primary_key)
    end

    def find(key)
      find_object(key: key).first
    end
    alias :[] :find

    def update(object)
{'fraction_non_alphanumeric': 0.10357815442561205, 'fraction_numerical': 0.00047080979284369113, 'mean_word_length': 2.949814126394052, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5680979', 'n_tokens_mistral': 657, 'n_tokens_neox': 644, 'n_words': 155}