<commit_before>module Archivist
  module ArchiveMethods
    def self.included(base)
      base.class_eval do
        extend ArchiveClassMethods
        protected :get_klass,:get_klass_name,:get_klass_instance_methods,:build_proxy_method
      end
    end

    def method_missing(method,*args,&block)
      if get_klass_instance_methods.include?(method.to_s)
        build_proxy_method(method.to_s)
        self.method(method).call(*args,&block)
      else
        super(method,*args,&block)
      end
    end

    def respond_to?(method,include_private=false)
      if get_klass_instance_methods.include?(method.to_s)
        return true
      else
        super(method,include_private)
      end
    end

    def get_klass
      @klass ||= Kernel.const_get(get_klass_name)
    end
    
    def get_klass_name
      @klass_name ||= self.class.to_s.split("::").first
    end

    def get_klass_instance_methods
      @klass_instance_methods ||= get_klass.instance_methods(false)
    end
    
    def build_proxy_method(method_name)
      class_eval <<-EOF
        def #{method_name}(*args,&block)
          instance = #{get_klass_name}.new
          instance.id = self.id
          attrs = self.attributes.select{|k,v| #{get_klass.new.attribute_names.inspect}.include?(k.to_s)}
          instance.attributes= attrs,false
          instance.#{method_name}(*args,&block)
        end
      EOF
    end

    module ArchiveClassMethods;end
  end
end
<commit_msg>maybe its best to not set the pk in our proxy object<commit_after>module Archivist
  module ArchiveMethods
    def self.included(base)
      base.class_eval do
        extend ArchiveClassMethods
        protected :get_klass,:get_klass_name,:get_klass_instance_methods,:build_proxy_method
      end
    end

    def method_missing(method,*args,&block)
      if get_klass_instance_methods.include?(method.to_s)
        build_proxy_method(method.to_s)
        self.method(method).call(*args,&block)
      else
        super(method,*args,&block)
      end
    end

    def respond_to?(method,include_private=false)
      if get_klass_instance_methods.include?(method.to_s)
        return true
      else
        super(method,include_private)
      end
    end

    def get_klass
      @klass ||= Kernel.const_get(get_klass_name)
    end
    
    def get_klass_name
      @klass_name ||= self.class.to_s.split("::").first
    end

    def get_klass_instance_methods
      @klass_instance_methods ||= get_klass.instance_methods(false)
    end
    
    def build_proxy_method(method_name)
      class_eval <<-EOF
        def #{method_name}(*args,&block)
          instance = #{get_klass_name}.new
          attrs = self.attributes.select{|k,v| #{get_klass.new.attribute_names.inspect}.include?(k.to_s)}
          instance.attributes= attrs,false
          instance.#{method_name}(*args,&block)
        end
      EOF
    end

    module ArchiveClassMethods;end
  end
end

{'fraction_non_alphanumeric': 0.09284001370332305, 'fraction_numerical': 0.0, 'mean_word_length': 2.8070404172099086, 'pattern_counts': {'":': 2, '<': 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': '5866735', 'n_tokens_mistral': 918, 'n_tokens_neox': 937, 'n_words': 153}