class Panda::Routing::Mapper
Attributes
endpoints[R]
request[R]
Public Class Methods
new(endpoints)
click to toggle source
# File lib/panda/routing/mapper.rb, line 6 def initialize(endpoints) @endpoints = endpoints end
Public Instance Methods
perform(request)
click to toggle source
# 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
Private Instance Methods
match_path_with_endpoint(path, endpoint)
click to toggle source
# File lib/panda/routing/mapper.rb, line 22 def match_path_with_endpoint(path, endpoint) regex, placeholders = endpoint[:pattern] if regex =~ path match_data = $~ placeholders.each do |placeholder| request.update_param(placeholder, match_data[placeholder]) end return true end end