title: How can I intercept method call in ruby?
body: <p>I currently have a superclass which has a function that I want all the subclass to call within each of its function. The function is supposed to behave like a before_filter function in rails but I am not sure on how to go about implementing before_filter. Here is an example</p>
  
  <pre><code>class Superclass
    def before_each_method
      puts "Before Method" #this is supposed to be invoked by each extending class' method
    end
  end
  
  class Subclass &lt; Superclass
    def my_method
      #when this method is called, before_each_method method is supposed to get invoked
    end
  end
  </code></pre>