Class: Rambo::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/rambo/request.rb

Direct Known Subclasses

ApplicationRequest

Instance Method Summary collapse

Instance Method Details

#acceptObject

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

#actionObject



46
47
48
# File 'lib/rambo/request.rb', line 46

def action
  path_components[2] || 'index'
end

#application_contextObject



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

#controllerObject



42
43
44
# File 'lib/rambo/request.rb', line 42

def controller
  path_components[1] || default_controller
end

#controller_classObject



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_controllerObject



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

#paramsObject

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

#pathObject



14
15
16
# File 'lib/rambo/request.rb', line 14

def path
  @env["REQUEST_PATH"]
end

#path_componentsObject



22
23
24
# File 'lib/rambo/request.rb', line 22

def path_components
  @path_components ||= path.split('/')
end

#uriObject



18
19
20
# File 'lib/rambo/request.rb', line 18

def uri
  @env["REQUEST_URI"]
end

#user_agentObject



5
6
7
# File 'lib/rambo/request.rb', line 5

def user_agent
  @env['HTTP_USER_AGENT']
end