<commit_before>module Norm
  class Repository
    NoRecordClassError = Class.new(Error)

    class << self

      def primary_keys=(key_or_keys)
        keys = Array(key_or_keys).map(&:to_s)
        define_method(:primary_keys) { keys }
      end
      alias :primary_key= :primary_keys=

      def default_record_class=(record_class)
        define_method(:default_record_class) { record_class }
      end

    end

    attr_reader :record_class

    def initialize(record_class = nil)
      @record_class = record_class || default_record_class
      require_record_class!
    end

    def load_attributes(attributes)
      attributes.each do |name, value|
        attributes[name] = record_class.load_attribute(name, value)
      end
      attributes
    end

    def default_record_class
    end

    def primary_keys
      record_class.identifying_attribute_names
    end

    def all
      raise NotImplementedError, 'Repositories must implement #all'
    end

    def fetch(*keys)
      raise NotImplementedError, 'Repositories must implement #fetch'
    end

    def store(record_or_records)
      raise NotImplementedError, 'Repositories must implement #store'
    end

    def insert(record_or_records)
      raise NotImplementedError, 'Repositories must implement #insert'
    end

    def update(record_or_records)
      raise NotImplementedError, 'Repositories must implement #update'
    end

    def delete(record_or_records)
      raise NotImplementedError, 'Repositories must implement #delete'
    end

    private

    def require_record_class!
      unless record_class
        raise NoRecordClassError,
          'Record class required. Set one, or specify default_record_class.'
      end
    end

  end
end

require 'norm/memory_repository'
require 'norm/postgresql_repository'<commit_msg>Oops. Need to stop requiring memory_repository<commit_after>module Norm
  class Repository
    NoRecordClassError = Class.new(Error)

    class << self

      def primary_keys=(key_or_keys)
        keys = Array(key_or_keys).map(&:to_s)
        define_method(:primary_keys) { keys }
      end
      alias :primary_key= :primary_keys=

      def default_record_class=(record_class)
        define_method(:default_record_class) { record_class }
      end

    end

    attr_reader :record_class

    def initialize(record_class = nil)
      @record_class = record_class || default_record_class
      require_record_class!
    end

    def load_attributes(attributes)
      attributes.each do |name, value|
        attributes[name] = record_class.load_attribute(name, value)
      end
      attributes
    end

    def default_record_class
    end

    def primary_keys
      record_class.identifying_attribute_names
    end

    def all
      raise NotImplementedError, 'Repositories must implement #all'
    end

    def fetch(*keys)
      raise NotImplementedError, 'Repositories must implement #fetch'
    end

    def store(record_or_records)
      raise NotImplementedError, 'Repositories must implement #store'
    end

    def insert(record_or_records)
      raise NotImplementedError, 'Repositories must implement #insert'
    end

    def update(record_or_records)
      raise NotImplementedError, 'Repositories must implement #update'
    end

    def delete(record_or_records)
      raise NotImplementedError, 'Repositories must implement #delete'
    end

    private

    def require_record_class!
      unless record_class
        raise NoRecordClassError,
          'Record class required. Set one, or specify default_record_class.'
      end
    end

  end
end

require 'norm/postgresql_repository'
{'fraction_non_alphanumeric': 0.059083379348426286, 'fraction_numerical': 0.0, 'mean_word_length': 3.061659192825112, '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': '774221', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1016, 'n_words': 262}