draper/lib/draper
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
..
compatibility Add support for Rails 5 API-only applications (#793) 2017-04-03 08:19:42 -05:00
decoratable Rename `source` to `object` 2013-04-30 14:10:52 +01:00
tasks remove old compatibility code 2016-07-04 16:07:06 -05:00
test Remove previously deprecated functionality. (#785) 2017-03-29 10:26:07 -05:00
view_context Add support for custom default controller configuration (#788) 2017-03-31 09:05:15 -05:00
automatic_delegation.rb Don't do runtime delegation, delegate explicitly (#789) 2017-04-03 11:24:01 -05:00
collection_decorator.rb Remove previously deprecated functionality. (#785) 2017-03-29 10:26:07 -05:00
configuration.rb Add support for custom default controller configuration (#788) 2017-03-31 09:05:15 -05:00
decoratable.rb Only Draper::Decorator types should delegate === to object. (#720) 2017-03-31 14:51:10 -05:00
decorated_association.rb Rename `source` to `object` 2013-04-30 14:10:52 +01:00
decorates_assigned.rb Revert "Merge pull request #480 from urbanautomaton/decorator-namespace-option" 2013-03-10 09:27:12 +01:00
decorator.rb Issue 725: Remove conflicting source alias (#786) 2017-03-29 10:27:33 -05:00
delegation.rb Rename `source` to `object` 2013-04-30 14:10:52 +01:00
factory.rb Decorate structs as singular objects (and not as collections) 2014-06-03 16:46:22 -04:00
finders.rb Remove executable bit from lib and spec source files (#718) 2017-03-27 22:39:17 -05:00
helper_proxy.rb Remove previously deprecated functionality. (#785) 2017-03-29 10:26:07 -05:00
helper_support.rb add new lines 😓 2012-04-25 23:12:30 +03:00
lazy_helpers.rb Documentation 2013-01-07 16:37:36 +00:00
railtie.rb Add support for custom default controller configuration (#788) 2017-03-31 09:05:15 -05:00
test_case.rb revert test_case.rb changes 2016-07-09 10:30:42 -05:00
undecorate.rb Add undecorate_chain feature 2017-01-16 00:47:54 +03:00
version.rb release 3.0.0.pre1 2016-07-10 13:02:37 -05:00
view_context.rb Remove previously deprecated functionality. (#785) 2017-03-29 10:26:07 -05:00
view_helpers.rb Store helper proxies instead of raw view contexts 2013-01-24 00:23:39 +00:00