draper/lib
Cliff Braton 31fa4793db Don't do runtime delegation, delegate explicitly (#789)
* 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.
2017-04-03 11:24:01 -05:00
..
draper Don't do runtime delegation, delegate explicitly (#789) 2017-04-03 11:24:01 -05:00
generators Fix warnings with recent thor versions 2017-02-25 10:56:32 -03:00
draper.rb Add support for Rails 5 API-only applications (#793) 2017-04-03 08:19:42 -05:00