class AutoForme::Request

Request wraps a specific web request for a given framework.

Attributes

action_type[R]

A string representing the action type for the request

controller[R]

The underlying web framework request instance for the request

env[R]

The HTTP request environment hash

id[R]

The id related to the request, which is usually the primary key of the related model instance.

method[R]

The request method (GET or POST) for the request

model[R]

A string representing the model for the request

params[R]

The params for the current request

path[R]

A string representing the path that the root of the application is mounted at

session[R]

The session variables for the current request

Public Instance Methods

post?() click to toggle source

Whether the current request used the POST HTTP method.

   # File lib/autoforme/request.rb
36 def post?
37   method == 'POST'
38 end
query_string() click to toggle source

The query string for the current request

   # File lib/autoforme/request.rb
41 def query_string
42   @env['QUERY_STRING']
43 end
set_flash_notice(message) click to toggle source

Set the flash at notice level when redirecting, so it shows up on the redirected page.

   # File lib/autoforme/request.rb
47 def set_flash_notice(message)
48   @controller.flash[:notice] = message
49 end
set_flash_now_error(message) click to toggle source

Set the current flash at error level, used when displaying pages when there is an error.

   # File lib/autoforme/request.rb
53 def set_flash_now_error(message)
54   @controller.flash.now[:error] = message
55 end

Private Instance Methods

set_id(path_id) click to toggle source
   # File lib/autoforme/request.rb
59 def set_id(path_id)
60   @id = path_id
61   if param_id = @params['id']
62     case @action_type
63     when 'show', 'edit', 'delete', 'mtm_edit'
64       @id = param_id
65     end
66   end
67   @id = nil if @id && @id.empty?
68 end