Class: AutoForme::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/autoforme/request.rb

Overview

Request wraps a specific web request for a given framework.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#action_typeObject (readonly)

A string representing the action type for the request



14
15
16
# File 'lib/autoforme/request.rb', line 14

def action_type
  @action_type
end

#controllerObject (readonly)

The underlying web framework request instance for the request



5
6
7
# File 'lib/autoforme/request.rb', line 5

def controller
  @controller
end

#idObject (readonly)

The id related to the request, which is usually the primary key of the related model instance, but for browse/search pages is used as the page



23
24
25
# File 'lib/autoforme/request.rb', line 23

def id
  @id
end

#methodObject (readonly)

The request method (GET or POST) for the request



8
9
10
# File 'lib/autoforme/request.rb', line 8

def method
  @method
end

#modelObject (readonly)

A string representing the model for the request



11
12
13
# File 'lib/autoforme/request.rb', line 11

def model
  @model
end

#paramsObject (readonly)

The params for the current request



26
27
28
# File 'lib/autoforme/request.rb', line 26

def params
  @params
end

#pathObject (readonly)

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



18
19
20
# File 'lib/autoforme/request.rb', line 18

def path
  @path
end

#sessionObject (readonly)

The session variables for the current request



29
30
31
# File 'lib/autoforme/request.rb', line 29

def session
  @session
end

Instance Method Details

#post?Boolean

Whether the current request used the POST HTTP method.

Returns:

  • (Boolean)


32
33
34
# File 'lib/autoforme/request.rb', line 32

def post?
  method == 'POST'
end

#query_stringObject

The query string for the current request



37
38
39
# File 'lib/autoforme/request.rb', line 37

def query_string
  @env['QUERY_STRING']
end

#set_flash_notice(message) ⇒ Object

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



43
44
45
# File 'lib/autoforme/request.rb', line 43

def set_flash_notice(message)
  @controller.flash[:notice] = message
end

#set_flash_now_error(message) ⇒ Object

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



49
50
51
# File 'lib/autoforme/request.rb', line 49

def set_flash_now_error(message)
  @controller.flash.now[:error] = message
end