提交 cd8eb351 编写于 作者: A Aaron Patterson

push content_type assigment in to metal

everything above metal really doesn't care about setting the content
type, so lets rearrange these methods to be in metal.
上级 7056e2aa
......@@ -24,9 +24,9 @@ def render(*args, &block)
options = _normalize_render(*args, &block)
self.response_body = render_to_body(options)
if options[:html]
_set_content_type Mime::HTML.to_s
_set_html_content_type
else
_set_content_type _get_content_type(rendered_format)
_set_rendered_content_type rendered_format
end
self.response_body
end
......@@ -106,10 +106,10 @@ def _process_options(options)
def _process_format(format)
end
def _get_content_type(rendered_format) # :nodoc:
def _set_html_content_type # :nodoc:
end
def _set_content_type(type) # :nodoc:
def _set_rendered_content_type(format) # :nodoc:
end
# Normalize args and options.
......
......@@ -191,7 +191,7 @@ def respond_to(*mimes)
if format = collector.negotiate_format(request)
_process_format(format)
_set_content_type _get_content_type format
_set_rendered_content_type format
response = collector.response
response ? response.call : render({})
else
......
......@@ -56,12 +56,14 @@ def _render_in_priorities(options)
nil
end
def _get_content_type(rendered_format)
self.content_type || rendered_format.to_s
def _set_html_content_type
self.content_type = Mime::HTML.to_s
end
def _set_content_type(format)
self.content_type = format
def _set_rendered_content_type(format)
unless response.content_type
self.content_type = format.to_s
end
end
# Normalize arguments by catching blocks and setting them on :update.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册