alphagov/whitehall — pull request #560 by h-lame (2013-05-21 12:51:35+00:00)
Title: Bye bye draper

Remove the Draper gem from whitehall. Replace our draper presenters with a very slim version of our own that just uses delegate to send messages down to the wrapped model. There's also a Collection Decorator to replace the ``PresenterClass.decorate(arel_scope)`` behaviour we got from Draper (e.g. a transparent wrapper around a scope or array that lets you further mutate the scope without losing the presenter-ification of the models that eventually come out of the scope). I've not checked to see if we really need that behaviour though, it may be we don't and a simple ``arel_scope.map {|i| Presenter.new(i, view_context) }`` would be enough (note that without it we might lose any kaminari pagination methods on our scopes).

There's a delegation helper called delegate_instance_methods_of which takes a class (or array of classes) and explicitly delegates all the instance methods of that class. It removes ``Object.instance_methods`` (but adds back in the special methods that rails adds like .blank? etc.). I'm unsure that this shouldn't subtract ``BasicObject.instance_methods`` instead, or not remove any methods at all. Current version of Draper has switched from this sort of model to just delegating anything that isn't defined on the presenter class directly, so maybe their approach is better?