Class: Sinatra::Hat::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatras-hat/response.rb

Overview

Tells Sinatra what to do next.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#makerObject (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, options={})
  begin
    options.each { |sym, value| @request.send(sym, value) }
    @request.erb "#{maker.prefix}/#{action}".to_sym
  rescue Errno::ENOENT
    no_template! "Can't find #{File.expand_path(File.join(views, action.to_s))}.erb"
  end
end