Class: Sinatra::Hat::Response
Overview
Tells Sinatra what to do next.
Instance Attribute Summary collapse
-
#maker ⇒ Object
readonly
Returns the value of attribute maker.
Instance Method Summary collapse
-
#initialize(maker, request) ⇒ Response
constructor
A new instance of Response.
- #redirect(*args) ⇒ Object
- #render(action, options = {}) ⇒ Object
Constructor Details
#initialize(maker, request) ⇒ Response
Returns a new instance of Response.
11 12 13 14 |
# File 'lib/sinatras-hat/response.rb', line 11 def initialize(maker, request) @maker = maker @request = request end |
Instance Attribute Details
#maker ⇒ Object (readonly)
Returns the value of attribute maker.
7 8 9 |
# File 'lib/sinatras-hat/response.rb', line 7 def maker @maker end |
Instance Method Details
#redirect(*args) ⇒ Object
25 26 27 |
# File 'lib/sinatras-hat/response.rb', line 25 def redirect(*args) @request.redirect url_for(*args) end |
#render(action, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/sinatras-hat/response.rb', line 16 def render(action, ={}) begin .each { |sym, value| @request.send(sym, value) } @request.erb "#{maker.prefix}/#{action}".to_sym rescue Errno::ENOENT no_template! "Can't find #{File.(File.join(views, action.to_s))}.erb" end end |