Class: Panda::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/panda/routing/mapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoints) ⇒ Mapper

Returns a new instance of Mapper.



6
7
8
# File 'lib/panda/routing/mapper.rb', line 6

def initialize(endpoints)
  @endpoints = endpoints
end

Instance Attribute Details

#endpointsObject (readonly)

Returns the value of attribute endpoints.



4
5
6
# File 'lib/panda/routing/mapper.rb', line 4

def endpoints
  @endpoints
end

#requestObject (readonly)

Returns the value of attribute request.



4
5
6
# File 'lib/panda/routing/mapper.rb', line 4

def request
  @request
end

Instance Method Details

#perform(request) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/panda/routing/mapper.rb', line 10

def perform(request)
  @request = request
  path = request.path_info
  verb = request.request_method

  endpoints[verb].detect do |endpoint|
    match_path_with_endpoint(path, endpoint)
  end
end