Tag: 涟漪

为什么包含此模块不会覆盖动态生成的方法?

我试图通过包含一个模块来覆盖动态生成的方法。 在下面的示例中,Ripple关联向表添加rows=方法。 我想调用那个方法,但之后还要做一些额外的事情。 我创建了一个模块来覆盖该方法,认为模块的row=能够调用super来使用现有方法。 class Table # Ripple association – creates rows= method many :rows, :class_name => Table::Row # Hacky first attempt to use the dynamically-created # method and also do additional stuff – I would actually # move this code elsewhere if it worked module RowNormalizer def rows=(*args) rows = super rows.map!(&:normalize_prior_year) end end […]