在Ruby类中,我覆盖了三种方法,并且在每种方法中,我基本上都做同样的事情:
class ExampleClass def confirmation_required? is_allowed && super end def postpone_email_change? is_allowed && super end def reconfirmation_required? is_allowed && super end end
是否有更紧凑的语法?如何缩短代码?
如何使用别名?
class ExampleClass def confirmation_required? is_allowed && super end alias postpone_email_change? confirmation_required? alias reconfirmation_required? confirmation_required? end