Module: Wrapit::MethodWrappable

Defined in:
lib/wrapit/method_wrappable.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/wrapit/method_wrappable.rb', line 2

def self.included(base)
  class << base
    private

    def method_wrappable(*args)
      class_eval do
        args.each do |method|
          define_method :"#{method}_naked" do
            self.class.superclass.instance_method(method).bind(self).call
          end

          define_method method do
            super().wrapped
          end
        end
      end
    end
  end
end