如何在模块中的任何其他方法之前始终运行模块方法

时间:2017-02-17 15:33:57

标签: ruby-on-rails

我有一个模块,我正在工作,我想以某种方式先调用另一个方法进行检查,然后运行被调用的实际方法。

我的模块结构是这样的

module Python
   module Api
     def call_this_method_everytime
       if A
         go ahead and call the actual method being called
       else
         stop here do not call he method it was supposed to call
       end
     end

     def when_i_call_this_method

     end

     def or_this_method

     end
   end
end

我找到了一些复杂的解决方案,但在我的情况下不起作用,因为大多数人想在拦截方法之前调用一个类。

任何线索?

0 个答案:

没有答案