Class: Rack::RestfulSubmit
- Inherits:
-
MethodOverride
- Object
- MethodOverride
- Rack::RestfulSubmit
- Defined in:
- lib/rack/rack-restful_submit.rb
Constant Summary collapse
- REWRITE_KEYWORD =
'__rewrite'.freeze
- REWRITE_MAP =
'__map'.freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RestfulSubmit
constructor
A new instance of RestfulSubmit.
Constructor Details
#initialize(app) ⇒ RestfulSubmit
Returns a new instance of RestfulSubmit.
7 8 9 |
# File 'lib/rack/rack-restful_submit.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rack/rack-restful_submit.rb', line 11 def call(env) if env["REQUEST_METHOD"] == "POST" req = Request.new(env) if req.params[REWRITE_KEYWORD] && req.params[REWRITE_MAP] action = req.params[REWRITE_KEYWORD].keys.first # Should be always just one. mapping = req.params[REWRITE_MAP][action] if mapping && mapping['url'] && mapping['method'] rewrite(env, mapping['url'], mapping['method']) else return super(env) end else return super(env) end end @app.call(env) end |