alias_method如何在ruby中工作。我怎样才能用它来实现DRY?

时间:2016-12-13 11:49:54

标签: ruby-on-rails

我在应用程序中看到了这行代码,但无法找到该方法 整个应用程序中的get_accounts。

  alias_method :get_accounts, :get_list_of_records

1 个答案:

答案 0 :(得分:2)

get_accountsget_list_of_records的别名方法。从未使用这一事实没有错(除了它冗余和令人困惑的事实)。可能在代码中的每个地方都使用了方法get_list_of_records的原始名称。由于它没有在任何地方使用,您可以安全地删除此行以避免任何进一步的混淆。