Module: Ground::Protocol::Render
- Includes:
- Rack::Utils
- Included in:
- State
- Defined in:
- lib/ground/protocol/render.rb,
lib/ground/protocol/render/template.rb
Defined Under Namespace
Modules: Template
Instance Method Summary collapse
- #forbid(content = nil) ⇒ Object
- #html(content, status = 200) ⇒ Object
- #json(content, status = 200) ⇒ Object
- #non_found(content) ⇒ Object
- #not_accept(content = nil) ⇒ Object
- #redirect(target, status = 302) ⇒ Object
- #text(content, status = 200) ⇒ Object
- #unauthorized(content = nil) ⇒ Object
- #xml(content, status = 200) ⇒ Object
Instance Method Details
#forbid(content = nil) ⇒ Object
26 27 28 |
# File 'lib/ground/protocol/render.rb', line 26 def forbid(content = nil) response_as 403, content end |
#html(content, status = 200) ⇒ Object
14 15 16 |
# File 'lib/ground/protocol/render.rb', line 14 def html(content, status = 200) response_with(content, status, 'text/html; charset=UTF-8') end |
#json(content, status = 200) ⇒ Object
6 7 8 |
# File 'lib/ground/protocol/render.rb', line 6 def json(content, status = 200) response_with(content, status, 'application/json; charset=UTF-8') end |
#non_found(content) ⇒ Object
22 23 24 |
# File 'lib/ground/protocol/render.rb', line 22 def non_found(content) response_as 404, content end |
#not_accept(content = nil) ⇒ Object
30 31 32 |
# File 'lib/ground/protocol/render.rb', line 30 def not_accept(content = nil) response_as 406, content end |
#redirect(target, status = 302) ⇒ Object
38 39 40 41 42 |
# File 'lib/ground/protocol/render.rb', line 38 def redirect(target, status = 302) response.status = status response['Location'] = target response.finish end |
#text(content, status = 200) ⇒ Object
18 19 20 |
# File 'lib/ground/protocol/render.rb', line 18 def text(content, status = 200) response_with(content, status, 'text/plain; charset=UTF-8') end |
#unauthorized(content = nil) ⇒ Object
34 35 36 |
# File 'lib/ground/protocol/render.rb', line 34 def (content = nil) response_as 401, content end |
#xml(content, status = 200) ⇒ Object
10 11 12 |
# File 'lib/ground/protocol/render.rb', line 10 def xml(content, status = 200) response_with(content, status, 'application/xml; charset=UTF-8') end |