Module: Mojito::Rendering::Content

Defined in:
lib/mojito/rendering/content.rb

Instance Method Summary collapse

Instance Method Details

#render_as(type, content, *args) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/mojito/rendering/content.rb', line 11

def render_as(type, content, *args)
	renderer = "to_#{type}".to_sym
	if content.respond_to? renderer
		response.write(content.send(renderer, *args[0...content.method(renderer).arity]))
	else
		Mojito::Rendering::StatusCodes.instance_method(:not_found!).bind(self).call
	end
end

#write(content) ⇒ Object



7
8
9
# File 'lib/mojito/rendering/content.rb', line 7

def write(content)
	response.write content
end