Class: Rambo::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Rambo::Request
- Defined in:
- lib/rambo/request.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#accept ⇒ Object
Returns an array of acceptable media types for the response.
- #action ⇒ Object
- #application_context ⇒ Object
- #application_context=(ctx) ⇒ Object
- #controller ⇒ Object
- #controller_class ⇒ Object
- #default_controller ⇒ Object
-
#params ⇒ Object
Override Rack 0.9.x’s #params implementation (see #72 in lighthouse).
- #path ⇒ Object
- #path_components ⇒ Object
- #uri ⇒ Object
- #user_agent ⇒ Object
Instance Method Details
#accept ⇒ Object
Returns an array of acceptable media types for the response
10 11 12 |
# File 'lib/rambo/request.rb', line 10 def accept @env['HTTP_ACCEPT'].to_s.split(',').map { |a| a.strip } end |
#action ⇒ Object
46 47 48 |
# File 'lib/rambo/request.rb', line 46 def action path_components[2] || 'index' end |
#application_context ⇒ Object
34 35 36 |
# File 'lib/rambo/request.rb', line 34 def application_context @application_context end |
#application_context=(ctx) ⇒ Object
38 39 40 |
# File 'lib/rambo/request.rb', line 38 def application_context=(ctx) @application_context = ctx end |
#controller ⇒ Object
42 43 44 |
# File 'lib/rambo/request.rb', line 42 def controller path_components[1] || default_controller end |
#controller_class ⇒ Object
50 51 52 |
# File 'lib/rambo/request.rb', line 50 def controller_class self.controller.downcase.gsub(/^[a-z]|\s+[a-z]/) { |a| a.upcase } + 'Controller' end |
#default_controller ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rambo/request.rb', line 26 def default_controller if rambo_conf = Rambo::Env.config['rambo'] rambo_conf['default_controller'] || 'home' else 'home' end end |
#params ⇒ Object
Override Rack 0.9.x’s #params implementation (see #72 in lighthouse)
55 56 57 58 59 |
# File 'lib/rambo/request.rb', line 55 def params self.GET.update(self.POST) rescue EOFError => boom self.GET end |
#path ⇒ Object
14 15 16 |
# File 'lib/rambo/request.rb', line 14 def path @env["REQUEST_PATH"] end |
#path_components ⇒ Object
22 23 24 |
# File 'lib/rambo/request.rb', line 22 def path_components @path_components ||= path.split('/') end |
#uri ⇒ Object
18 19 20 |
# File 'lib/rambo/request.rb', line 18 def uri @env["REQUEST_URI"] end |
#user_agent ⇒ Object
5 6 7 |
# File 'lib/rambo/request.rb', line 5 def user_agent @env['HTTP_USER_AGENT'] end |