From b20c0c527c89ec08548849163388d43207609fcd Mon Sep 17 00:00:00 2001 From: Gibheer Date: Tue, 18 Dec 2012 04:24:24 +0100 Subject: reuse render for actual rendering The splitting of rendering and processing is good, but on the other side it makes some double steps or even introduce workarounds. That is why I made the method #render just a call to the renderer. This should help much more than the strict seperation. The method will only return the resulting string and not add it to the body of the response. That still has to be taken care of by the user. --- lib/zero/controller.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/zero/controller.rb b/lib/zero/controller.rb index b42e500..ce9e247 100644 --- a/lib/zero/controller.rb +++ b/lib/zero/controller.rb @@ -56,13 +56,22 @@ module Zero # build the response and return it # - # This method calls #process if it was defined so make it easier to process - # the request before rendering stuff. + # This method calls #process. #process has to be provided by the actual + # implementation and should do all processing necessary to provide the + # content. # @return Response a rack conform response def response - process if respond_to?(:process) - render + process @response.to_a end + + # renders a template + # + # This method calls #render of the provided renderer and gives it the + # template name and accept types, so that the renderer can search for the + # appropiate template to render. + def render(template) + @renderer.render(template, @request.accept.types, self) + end end end -- cgit v1.2.3-70-g09d2