lib/lotus/rendering_policy.rb in lotusrb-0.5.0 vs lib/lotus/rendering_policy.rb in lotusrb-0.6.0
- old
+ new
@@ -25,11 +25,11 @@
end
def render(env, response)
body = _render(env, response)
- response[BODY] = Array(body) unless body.nil?
+ response[BODY] = Array(body) unless body.nil? || body.respond_to?(:each)
response
end
private
def _render(env, response)
@@ -64,10 +64,10 @@
def render_status_page?(action, response)
RENDERABLE_FORMATS.include?(action.format)
end
def view_for(action, response)
- if response[BODY].empty?
+ if response[BODY].respond_to?(:empty?) && response[BODY].empty?
captures = @controller_pattern.match(action.class.name)
Utils::Class.load!(@view_pattern % { controller: captures[:controller], action: captures[:action] }, @namespace)
else
Views::NullView.new(response[BODY])
end