<commit_before>module Leech
  class Surrogate
    attr_accessor :host, :victim

    def initialize(h, v)
      self.host = h
      self.victim = v.clone
    end

    def copy_methods
      _host = host
      common_methods.each do |method|
        victim.define_singleton_method(method) do |*args|
          _host.send(method, *args)
        end
      end
    end

    def method_missing(method, *args)
      if victim.respond_to?(method)
        victim.send(method, *args)
      else
        super(method, *args)
      end
    end

    private
    def common_methods
      ((host.methods + host.private_methods(false)) & (victim.methods + victim.private_methods(false))) - Object.instance_methods
    end
  end
end<commit_msg>safe sending of messages with __send__<commit_after>module Leech
  class Surrogate
    attr_accessor :host, :victim

    def initialize(h, v)
      self.host = h
      self.victim = v.clone
    end

    def copy_methods
      _host = host
      common_methods.each do |method|
        victim.define_singleton_method(method) do |*args|
          _host.__send__(method, *args)
        end
      end
    end

    def method_missing(method, *args)
      if victim.respond_to?(method)
        victim.__send__(method, *args)
      else
        super(method, *args)
      end
    end

    private
    def common_methods
      ((host.methods + host.private_methods(false)) & (victim.methods + victim.private_methods(false))) - Object.instance_methods
    end
  end
end
{'fraction_non_alphanumeric': 0.08742434431741762, 'fraction_numerical': 0.0, 'mean_word_length': 2.381818181818182, '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': '5411384', 'n_tokens_mistral': 472, 'n_tokens_neox': 461, 'n_words': 110}