Class: WelltreatStoreFramework::Controller::Response
- Inherits:
-
Object
- Object
- WelltreatStoreFramework::Controller::Response
- Defined in:
- lib/welltreat_store_framework/controller.rb
Constant Summary collapse
- STATUS_OK =
200
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#controller_name ⇒ Object
Returns the value of attribute controller_name.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#status ⇒ Object
Returns the value of attribute status.
-
#template ⇒ Object
Returns the value of attribute template.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #add_header(k, v) ⇒ Object
- #exists?(k) ⇒ Boolean
- #get(k) ⇒ Object
- #get_header(k) ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #present?(k) ⇒ Boolean
- #redirect? ⇒ Boolean
- #redirect_to(path, status = 302) ⇒ Object
- #set(k, v) ⇒ Object
Constructor Details
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
74 75 76 |
# File 'lib/welltreat_store_framework/controller.rb', line 74 def content @content end |
#controller_name ⇒ Object
Returns the value of attribute controller_name.
74 75 76 |
# File 'lib/welltreat_store_framework/controller.rb', line 74 def controller_name @controller_name end |
#headers ⇒ Object
Returns the value of attribute headers.
74 75 76 |
# File 'lib/welltreat_store_framework/controller.rb', line 74 def headers @headers end |
#layout ⇒ Object
Returns the value of attribute layout.
74 75 76 |
# File 'lib/welltreat_store_framework/controller.rb', line 74 def layout @layout end |
#status ⇒ Object
Returns the value of attribute status.
74 75 76 |
# File 'lib/welltreat_store_framework/controller.rb', line 74 def status @status end |
#template ⇒ Object
Returns the value of attribute template.
74 75 76 |
# File 'lib/welltreat_store_framework/controller.rb', line 74 def template @template end |
#values ⇒ Object
Returns the value of attribute values.
74 75 76 |
# File 'lib/welltreat_store_framework/controller.rb', line 74 def values @values end |
Instance Method Details
#[](k) ⇒ Object
107 108 109 |
# File 'lib/welltreat_store_framework/controller.rb', line 107 def [](k) self.get(k) end |
#add_header(k, v) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/welltreat_store_framework/controller.rb', line 86 def add_header(k, v) case k.to_s when 'content_type', 'format' @headers['Content-Type'] = v else @headers[k] = v end end |
#exists?(k) ⇒ Boolean
111 112 113 |
# File 'lib/welltreat_store_framework/controller.rb', line 111 def exists?(k) @values.include?(k) end |
#get(k) ⇒ Object
103 104 105 |
# File 'lib/welltreat_store_framework/controller.rb', line 103 def get(k) @values[k] end |
#get_header(k) ⇒ Object
95 96 97 |
# File 'lib/welltreat_store_framework/controller.rb', line 95 def get_header(k) @headers[k] end |
#present?(k) ⇒ Boolean
115 116 117 |
# File 'lib/welltreat_store_framework/controller.rb', line 115 def present?(k) exists?(k) && get(k).present? end |
#redirect? ⇒ Boolean
125 126 127 |
# File 'lib/welltreat_store_framework/controller.rb', line 125 def redirect? [301, 302, 303, 307].include? self.status end |
#redirect_to(path, status = 302) ⇒ Object
119 120 121 122 123 |
# File 'lib/welltreat_store_framework/controller.rb', line 119 def redirect_to(path, status = 302) self.status = status self.add_header("Location", path) self.content = '' end |
#set(k, v) ⇒ Object
99 100 101 |
# File 'lib/welltreat_store_framework/controller.rb', line 99 def set(k, v) @values[k] = v end |