观察你自己的方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了观察你自己的方法相关的知识,希望对你有一定的参考价值。

Rails builds on the standard Ruby observer, so you can too.

Originally found at http://rails.techno-weenie.net/forums/1/topics/672?page=6,
so don't give me any credit ;)
  1. def my_method!
  2. #- Your Method Code Here -#
  3. self.class.changed
  4. self.class.notify_observers(:my_method, self)
  5. end
  6.  
  7. That will call any observers 'my_method' method.

以上是关于观察你自己的方法的主要内容,如果未能解决你的问题,请参考以下文章