Class: Cuprum::Rails::Responses::Html::RedirectResponse
- Inherits:
-
Object
- Object
- Cuprum::Rails::Responses::Html::RedirectResponse
- Defined in:
- lib/cuprum/rails/responses/html/redirect_response.rb
Overview
Encapsulates an HTML response that redirects to a given path.
Instance Attribute Summary collapse
-
#flash ⇒ Hash
readonly
The flash messages to set.
-
#path ⇒ String
readonly
The path or url to redirect to.
-
#status ⇒ Integer
readonly
The HTTP status of the response.
Instance Method Summary collapse
-
#call(renderer) ⇒ Object
Calls the renderer’s #redirect_to method with the path and status.
-
#initialize(path, flash: {}, status: 302) ⇒ RedirectResponse
constructor
A new instance of RedirectResponse.
Constructor Details
#initialize(path, flash: {}, status: 302) ⇒ RedirectResponse
Returns a new instance of RedirectResponse.
11 12 13 14 15 |
# File 'lib/cuprum/rails/responses/html/redirect_response.rb', line 11 def initialize(path, flash: {}, status: 302) @flash = flash @path = path @status = status end |
Instance Attribute Details
#flash ⇒ Hash (readonly)
Returns the flash messages to set.
18 19 20 |
# File 'lib/cuprum/rails/responses/html/redirect_response.rb', line 18 def flash @flash end |
#path ⇒ String (readonly)
Returns the path or url to redirect to.
21 22 23 |
# File 'lib/cuprum/rails/responses/html/redirect_response.rb', line 21 def path @path end |
#status ⇒ Integer (readonly)
Returns the HTTP status of the response.
24 25 26 |
# File 'lib/cuprum/rails/responses/html/redirect_response.rb', line 24 def status @status end |
Instance Method Details
#call(renderer) ⇒ Object
Calls the renderer’s #redirect_to method with the path and status.
30 31 32 33 34 |
# File 'lib/cuprum/rails/responses/html/redirect_response.rb', line 30 def call(renderer) assign_flash(renderer) renderer.redirect_to(path, status: status) end |