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



16
17
18
# File 'lib/autoforme/request.rb', line 16

def action_type
  @action_type
end

#controllerObject (readonly)

The underlying web framework request instance for the request



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

def controller
  @controller
end

#envObject (readonly)

The HTTP request environment hash



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

def env
  @env
end

#idObject (readonly)

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



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

def id
  @id
end

#methodObject (readonly)

The request method (GET or POST) for the request



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

def method
  @method
end

#modelObject (readonly)

A string representing the model for the request



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

def model
  @model
end

#paramsObject (readonly)

The params for the current request



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

def params
  @params
end

#pathObject (readonly)

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



20
21
22
# File 'lib/autoforme/request.rb', line 20

def path
  @path
end

#sessionObject (readonly)

The session variables for the current request



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

def session
  @session
end

Instance Method Details

#post?Boolean

Whether the current request used the POST HTTP method.

Returns:

  • (Boolean)


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

def post?
  method == 'POST'
end

#query_stringObject

The query string for the current request



41
42
43
# File 'lib/autoforme/request.rb', line 41

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.



47
48
49
# File 'lib/autoforme/request.rb', line 47

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.



53
54
55
# File 'lib/autoforme/request.rb', line 53

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