Module: WEBrick::RouteServlet::ClassMethods
- Defined in:
- lib/webrick/route_servlet.rb
Instance Attribute Summary collapse
-
#error500 ⇒ Object
Returns the value of attribute error500.
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 Attribute Details
#error500 ⇒ Object
Returns the value of attribute error500.
82 83 84 |
# File 'lib/webrick/route_servlet.rb', line 82 def error500 @error500 end |
Instance Method Details
#match(re, servlet, *servlet_options, **request_options) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/webrick/route_servlet.rb', line 84 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
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/webrick/route_servlet.rb', line 125 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
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/webrick/route_servlet.rb', line 106 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
92 93 94 95 |
# File 'lib/webrick/route_servlet.rb', line 92 def root(servlet, *, **) @routes ||= [] @routes.unshift([:*, _normalize_path_re("/", ), servlet, , ]) end |
#routes ⇒ Object
143 144 145 |
# File 'lib/webrick/route_servlet.rb', line 143 def routes @routes ||= [] end |