class NetMate::Routing
Public Instance Methods
get(path)
click to toggle source
# File lib/net_mate/routing.rb, line 5 def get path match path, to: path.tr('/','#'), via: 'get' end
match(path, options)
click to toggle source
# File lib/net_mate/routing.rb, line 13 def match path, options path = path == '/' ? path : "/#{path}" controller, action = options[:to].split('#') NetMate::routes[[path, options[:via]]] = [controller, action] end
post(path)
click to toggle source
# File lib/net_mate/routing.rb, line 9 def post path match path, to: path.tr('/','#'), via: 'post' end
resources(controller, options = { only: [:new, :create, :edit, :update, :show, :index] })
click to toggle source
# File lib/net_mate/routing.rb, line 19 def resources controller, options = { only: [:new, :create, :edit, :update, :show, :index] } options[:only].each do |action| action = action.to_s controller = controller.to_s path = "/#{controller}/#{action}" method = ['create', 'update'].include?(action) ? 'post' : 'get' NetMate::routes[[path, method]] = [controller, action] end end