Module: Pwnlib::Ext::Helper

Included in:
Array::InstanceMethods, Integer::InstanceMethods, String::InstanceMethods
Defined in:
lib/pwnlib/ext/helper.rb

Overview

Helper methods for defining extension.

Instance Method Summary collapse

Instance Method Details

#def_proxy_method(mod, *ms, **m2) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pwnlib/ext/helper.rb', line 8

def def_proxy_method(mod, *ms, **m2)
  ms.flatten
    .map { |x| [x, x] }
    .concat(m2.to_a)
    .each do |method, proxy_to|
      class_eval(<<-EOS, __FILE__, __LINE__ + 1)
        def #{method}(*args, **kwargs, &block)
        #{mod}.#{proxy_to}(self, *args, **kwargs, &block)
        end
      EOS
    end
end