class AutoForme::Frameworks::Sinatra::Request

  1. lib/autoforme/frameworks/sinatra.rb
Superclass: Request

Methods

Public Class

  1. new

Public Instance

  1. csrf_token_hash
  2. redirect
  3. xhr?

Public Class methods

new (controller)
[show source]
# File lib/autoforme/frameworks/sinatra.rb, line 6
def initialize(controller)
  @controller = controller
  @request = controller.request
  @params = controller.params
  @session = controller.session
  captures = @params[:captures] || []
  @env = @request.env
  @method = @env['REQUEST_METHOD']
  @model = captures[0]
  @action_type = captures[1]
  @path = @env['SCRIPT_NAME']
  set_id(captures[2])
end

Public Instance methods

csrf_token_hash ()

Use Rack::Csrf for csrf protection if it is defined.

[show source]
# File lib/autoforme/frameworks/sinatra.rb, line 31
def csrf_token_hash
  {::Rack::Csrf.field=>::Rack::Csrf.token(@env)} if defined?(::Rack::Csrf)
end
redirect (path)

Redirect to the given path

[show source]
# File lib/autoforme/frameworks/sinatra.rb, line 21
def redirect(path)
  controller.redirect(path)
end
xhr? ()

Whether the request is an asynchronous request

[show source]
# File lib/autoforme/frameworks/sinatra.rb, line 26
def xhr?
  @env['HTTP_X_REQUESTED_WITH'] =~ /XMLHttpRequest/i
end