From aea02eb43001d85def0e69dce76fde0757040089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Tue, 3 Sep 2013 14:57:33 +0200 Subject: [PATCH] Move skeleton methods from AV to AbsC The methods: * #render_to_body * #render_to_string * #_normalize_render Haven't had anything specyfic to ActionView. This was common code which should belong to AbstractController --- .../lib/abstract_controller/rendering.rb | 26 ++++++++++++++----- actionview/lib/action_view/rendering.rb | 22 ---------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index a3c45bacb7..c74bbafdec 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -18,6 +18,12 @@ module AbstractController self.protected_instance_variables = [] end + # Normalize arguments, options and then delegates render_to_body and + # sticks the result in self.response_body. + # :api: public + def render(*args, &block) + end + # Raw rendering of a template to a string. # # It is similar to render, except that it does not @@ -30,17 +36,15 @@ module AbstractController # overridden in order to still return a string. # :api: plugin def render_to_string(*args, &block) + options = _normalize_render(*args, &block) + render_to_body(options) end # Raw rendering of a template. - # :api: plugin - def render_to_body(options = {}) - end - - # Normalize arguments, options and then delegates render_to_body and - # sticks the result in self.response_body. # :api: public - def render(*args, &block) + def render_to_body(options = {}) + _process_options(options) + _render_template(options) end # Return Content-Type of rendered content @@ -83,5 +87,13 @@ module AbstractController def _process_options(options) options end + + # Normalize args and options. + # :api: private + def _normalize_render(*args, &block) + options = _normalize_args(*args, &block) + _normalize_options(options) + options + end end end diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb index 478ee361e0..c1945cc0c5 100644 --- a/actionview/lib/action_view/rendering.rb +++ b/actionview/lib/action_view/rendering.rb @@ -84,20 +84,6 @@ module ActionView self.response_body = render_to_body(options) end - # Raw rendering of a template to a string. - # :api: public - def render_to_string(*args, &block) - options = _normalize_render(*args, &block) - render_to_body(options) - end - - # Raw rendering of a template. - # :api: public - def render_to_body(options = {}) - _process_options(options) - _render_template(options) - end - # Find and renders a template based on the options given. # :api: private def _render_template(options) #:nodoc: @@ -111,14 +97,6 @@ module ActionView private - # Normalize args and options. - # :api: private - def _normalize_render(*args, &block) - options = _normalize_args(*args, &block) - _normalize_options(options) - options - end - # Normalize args by converting render "foo" to render :action => "foo" and # render "foo/bar" to render :file => "foo/bar". # :api: private