class Mgt::Routing::Router
Attributes
endpoints[RW]
Public Instance Methods
draw(&block)
click to toggle source
# File lib/routing/router.rb, line 5 def draw(&block) instance_eval &block end
root(to)
click to toggle source
# File lib/routing/router.rb, line 9 def root(to) get "/", to: to end
Private Instance Methods
controller_and_action_for(path_to)
click to toggle source
# File lib/routing/router.rb, line 28 def controller_and_action_for(path_to) controller_path, action = path_to.split("#") controller = "#{controller_path.capitalize}Controller" [controller, action.to_sym] end
pattern(path)
click to toggle source
# File lib/routing/router.rb, line 19 def pattern(path) placeholders = [] path.gsub!(/(:\w+)/) do |match| placeholders << match[1..-1].freeze "(?<#{placeholders.last}>[^/?#]+)" end [/^#{path}$/, placeholders] end