在具有ruby的模型中查找称为当前方法的方法

时间:2013-03-02 12:10:30

标签: ruby-on-rails ruby ruby-on-rails-3.2

我需要找到一个名为“abc”的方法,基于我可以做一些操作。

Class A
  def method1
   abc
  end

  def method2
   abc
  end

  def abc
   puts "abc" if calling_method == :method1
   puts "xyz" 
  end
end

红宝石可以吗?

1 个答案:

答案 0 :(得分:4)