Class: HttpRouter::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/http_router/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, rack_request, perform_call) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
12
13
14
# File 'lib/http_router/request.rb', line 6

def initialize(path, rack_request, perform_call)
  @rack_request, @perform_call = rack_request, perform_call
  @path = URI.unescape(path).split(/\//)
  @path.shift if @path.first == ''
  @path.push('') if path[-1] == ?/
  @extra_env = {}
  @params = []
  @matches = []
end

Instance Attribute Details

#continueObject

Returns the value of attribute continue.



3
4
5
# File 'lib/http_router/request.rb', line 3

def continue
  @continue
end

#extra_envObject

Returns the value of attribute extra_env.



3
4
5
# File 'lib/http_router/request.rb', line 3

def extra_env
  @extra_env
end

#matchesObject (readonly)

Returns the value of attribute matches.



4
5
6
# File 'lib/http_router/request.rb', line 4

def matches
  @matches
end

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'lib/http_router/request.rb', line 3

def params
  @params
end

#passed_withObject

Returns the value of attribute passed_with.



3
4
5
# File 'lib/http_router/request.rb', line 3

def passed_with
  @passed_with
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/http_router/request.rb', line 3

def path
  @path
end

#rack_requestObject Also known as: rack

Returns the value of attribute rack_request.



3
4
5
# File 'lib/http_router/request.rb', line 3

def rack_request
  @rack_request
end

Instance Method Details

#joined_pathObject



16
17
18
# File 'lib/http_router/request.rb', line 16

def joined_path
  @path * '/'
end

#matched_route(response) ⇒ Object



20
21
22
# File 'lib/http_router/request.rb', line 20

def matched_route(response)
  @matches << response
end

#path_finished?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/http_router/request.rb', line 36

def path_finished?
  @path.size == 0 or @path.size == 1 && @path.first == ''
end

#perform_callObject



24
25
26
# File 'lib/http_router/request.rb', line 24

def perform_call
  @perform_call == true
end

#testing_405?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/http_router/request.rb', line 28

def testing_405?
  @perform_call == 405
end

#to_sObject



32
33
34
# File 'lib/http_router/request.rb', line 32

def to_s
  "request path, #{path.inspect}"
end