class Route
Attributes
action_name[R]
controller_class[R]
http_method[R]
pattern[R]
Public Class Methods
new(pattern, http_method, controller_class, action_name)
click to toggle source
# File lib/router.rb, line 4 def initialize(pattern, http_method, controller_class, action_name) @pattern = pattern @http_method = http_method @controller_class = controller_class @action_name = action_name end
Public Instance Methods
matches?(req)
click to toggle source
# File lib/router.rb, line 11 def matches?(req) return false if (pattern =~ req.path).nil? req_method = req.params["_method"] || req.request_method req_method.upcase == http_method.to_s.upcase end
run(req, res)
click to toggle source
# File lib/router.rb, line 19 def run(req, res) matched_params = pattern.match(req.path) params = {} matched_params.names.each do |param_key| params[param_key] = matched_params[param_key] end controller_class.new(req, res, params).invoke_action(action_name) end