Module: WEBrick::RouteServlet::ClassMethods
- Defined in:
- lib/webrick/route_servlet.rb
Instance Method Summary collapse
- #match(re, servlet, *servlet_options, **request_options) ⇒ Object
- #resource(re, servlet, *servlet_options, **request_options) ⇒ Object
- #resources(re, servlet, *servlet_options, **request_options) ⇒ Object
- #root(servlet, *servlet_options, **request_options) ⇒ Object
- #routes ⇒ Object
Instance Method Details
#match(re, servlet, *servlet_options, **request_options) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/webrick/route_servlet.rb', line 75 def match(re, servlet, *, **) @routes ||= [] re = _normalize_path_re(re, ) _select_via().each do |via| @routes << [via, re, servlet, , ] end end |
#resource(re, servlet, *servlet_options, **request_options) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/webrick/route_servlet.rb', line 116 def resource(re, servlet, *, **) re = re.to_s.sub(%r#/$#, "") actions = { :create => [:post, "#{re}(.:format)"], :new => [:get, "#{re}/new(.:format)"], :edit => [:get, "#{re}/edit(.:format)"], :show => [:get, "#{re}(.:format)"], :update => [:put, "#{re}(.:format)"], :destroy => [:delete, "#{re}(.:format)"], } _select_rest_actions(actions, ) actions.each do |action, (method, re)| send(method, re, servlet, *, .merge({:action => action})) end end |
#resources(re, servlet, *servlet_options, **request_options) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/webrick/route_servlet.rb', line 97 def resources(re, servlet, *, **) re = re.to_s.sub(%r#/$#, "") actions = { :index => [:get, "#{re}(.:format)"], :create => [:post, "#{re}(.:format)"], :new => [:get, "#{re}/new(.:format)"], :edit => [:get, "#{re}/:id/edit(.:format)"], :show => [:get, "#{re}/:id(.:format)"], :update => [:put, "#{re}/:id(.:format)"], :destroy => [:delete, "#{re}/:id(.:format)"], } _select_rest_actions(actions, ) actions.each do |action, (method, re)| send(method, re, servlet, *, .merge({:action => action})) end end |
#root(servlet, *servlet_options, **request_options) ⇒ Object
83 84 85 86 |
# File 'lib/webrick/route_servlet.rb', line 83 def root(servlet, *, **) @routes ||= [] @routes.unshift([:*, _normalize_path_re("/", ), servlet, , ]) end |
#routes ⇒ Object
134 135 136 |
# File 'lib/webrick/route_servlet.rb', line 134 def routes @routes ||= [] end |