Module: Lunetas::Candy::RequestWrapper::InstanceMethods
- Defined in:
- lib/lunetas/candy/request_wrapper.rb
Instance Method Summary collapse
-
#development? ⇒ true, false
Is lunetas running in development?.
-
#params ⇒ Hash
Gets the request parameters.
-
#redirect(target, status = 302) ⇒ nil
Redirects to some location.
-
#request ⇒ Rack::Request
Gets the current request object.
-
#session ⇒ Hash
Gets the current session.
-
#set_content_type(content_type) ⇒ nil
Sets the ContentType for this instance.
-
#set_header(header, value) ⇒ nil
Sets a Header for this instance.
-
#xhr? ⇒ true, false
Called from an XML Http Request?.
Instance Method Details
#development? ⇒ true, false
Is lunetas running in development?
40 41 42 43 44 45 46 |
# File 'lib/lunetas/candy/request_wrapper.rb', line 40 def development? if ENV['RAILS_ENV'] ENV['RAILS_ENV'] == 'development' else ENV['RACK_ENV'].nil? || ENV['RACK_ENV'] == 'development' end end |
#params ⇒ Hash
Gets the request parameters.
13 14 15 |
# File 'lib/lunetas/candy/request_wrapper.rb', line 13 def params @req.params end |
#redirect(target, status = 302) ⇒ nil
Redirects to some location.
33 34 35 36 |
# File 'lib/lunetas/candy/request_wrapper.rb', line 33 def redirect(target, status = 302) set_header 'Location', target @lunetas_redirect = [302, "Moved to #{target}"] end |
#request ⇒ Rack::Request
Gets the current request object.
19 20 21 |
# File 'lib/lunetas/candy/request_wrapper.rb', line 19 def request @req end |
#session ⇒ Hash
Gets the current session.
25 26 27 |
# File 'lib/lunetas/candy/request_wrapper.rb', line 25 def session @req.session end |
#set_content_type(content_type) ⇒ nil
Sets the ContentType for this instance. This overrides the class ContentType.
52 53 54 |
# File 'lib/lunetas/candy/request_wrapper.rb', line 52 def set_content_type(content_type) set_header 'Content-Type', content_type end |
#set_header(header, value) ⇒ nil
Sets a Header for this instance.
60 61 62 |
# File 'lib/lunetas/candy/request_wrapper.rb', line 60 def set_header(header, value) @lunetas_headers[header.to_s] = value end |
#xhr? ⇒ true, false
Called from an XML Http Request?
7 8 9 |
# File 'lib/lunetas/candy/request_wrapper.rb', line 7 def xhr? @req.xhr? end |