Module: Tinymethodwrapper::ClassMethods

Defined in:
lib/tinymethodwrapper.rb

Instance Method Summary collapse

Instance Method Details

#wrap_methods(method_arr, function) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/tinymethodwrapper.rb', line 12

def wrap_methods(method_arr, function)
  method_arr.each do |method_name|
    old_method = instance_method(method_name)
    define_method(method_name) do |*args, &block|
      function.call(method_name)
      old_method.bind(self).call(*args, &block)
    end
  end
end