class Schmetterling::Before

Public Class Methods

new(klass, method, advice=nil, &block) click to toggle source
# File lib/schmetterling/before.rb, line 4
def initialize(klass, method, advice=nil, &block)
  advice ||= block
  klass.send(:prepend, build_module_for_advice(method, advice))
end

Public Instance Methods

build_module_for_advice(adviced_method, advice) click to toggle source
Calls superclass method
# File lib/schmetterling/before.rb, line 9
def build_module_for_advice(adviced_method, advice)
  Module.new do
    define_method adviced_method do |*args|
      advice.call(self, *args)
      super(*args)
    end
  end
end