我可以在执行方法之前让对象重新初始化吗?我正在使用 Ruby 和 selenium 来测试一个网络应用程序,并且我正在尝试改进我的页面对象。例如
class Foo
def initialize
#stuff happens here
end
def NewMethod
self.initialize
#What happens here is what I really want to happen
end
end
这是个好主意还是坏主意?还是有更好的方法来做到这一点?