module Hobby::Helpers

Attributes

env[R]
route[R]

Public Instance Methods

content_type(type) click to toggle source
# File lib/hobby/helpers.rb, line 37
def content_type type
  mime_type = Rack::Mime::MIME_TYPES.fetch ".#{type}"
  response.add_header 'Content-Type', mime_type
end
halt() click to toggle source
# File lib/hobby/helpers.rb, line 29
def halt
  throw :halt, response.to_a
end
my() click to toggle source
# File lib/hobby/helpers.rb, line 25
def my
  route.params
end
not_found() click to toggle source
# File lib/hobby/helpers.rb, line 33
def not_found
  response.status = 404
end
request() click to toggle source
# File lib/hobby/helpers.rb, line 17
def request
  @request ||= self.class.request.new env
end
response() click to toggle source
# File lib/hobby/helpers.rb, line 21
def response
  @response ||= self.class.response.new
end
router() click to toggle source
# File lib/hobby/helpers.rb, line 7
def router
  @router ||= begin
                router = self.class.router.clone
                router.app = self
                router
              end
end
script_name() click to toggle source
# File lib/hobby/helpers.rb, line 46
def script_name
  env.fetch 'SCRIPT_NAME'
end
status(status) click to toggle source
# File lib/hobby/helpers.rb, line 42
def status status
  response.status = status
end