![]() * Don't do runtime delegation, delegate explicitly If someone accidentally calls `super` instead of `object` inside a decorator, all hell breaks loose. ```rb class Post < ActiveRecord::Base def title "title" end end class PostDecorator < Draper::Decorator delegate_all def title super and "overriden title" end end post = PostDecorator.new(Post.new) post.title #=> "overriden title" post.title #=> "title" ``` This patch makes both `super` and `object` work. I'm not sure why runtime delegation was added in the first place, but it seems very wrong to add methods on the fly. * Add documentation and more tests. * Consistent line spacing in test. |
||
---|---|---|
.. | ||
draper | ||
generators | ||
draper.rb |