"Middleware#remove" is renamed "Middleware#delete!"
This commit intends to clarify the difference between `Middleware#delete` and `Middleware#delete!`. The former method silently fails when the target item is not found, while the latter raises an error. The functionality of `delete!` has been introduced in 688ed70 and given a name `remove`. This commit only renames it. Also, a brief description of `delete!` method is now provided for guides so that users can acknowledge the difference.
This commit is contained in:
parent
1488cb8440
commit
aff17a82f6
@ -1,3 +1,10 @@
|
||||
* Add `Middleware#delete!` to delete middleware or raise if not found.
|
||||
|
||||
`Middleware#delete!` works just like `Middleware#delete` but will
|
||||
raise an error if the middleware isn't found.
|
||||
|
||||
*Alex Ghiculescu*, *Petrik de Heus*, *Junichi Sato*
|
||||
|
||||
* Raise error on unpermitted open redirects.
|
||||
|
||||
Add `allow_other_host` options to `redirect_to`.
|
||||
@ -13,13 +20,6 @@
|
||||
|
||||
*Yusuke Iwaki*
|
||||
|
||||
* Add `Middleware#remove` to delete middleware or raise if not found.
|
||||
|
||||
`Middleware#remove` works just like `Middleware#delete` but will
|
||||
raise an error if the middleware isn't found.
|
||||
|
||||
*Alex Ghiculescu*, *Petrik de Heus*
|
||||
|
||||
* Exclude additional flash types from `ActionController::Base.action_methods`.
|
||||
|
||||
Ensures that additional flash types defined on ActionController::Base subclasses
|
||||
|
@ -133,7 +133,7 @@ def delete(target)
|
||||
middlewares.reject! { |m| m.name == target.name }
|
||||
end
|
||||
|
||||
def remove(target)
|
||||
def delete!(target)
|
||||
delete(target) || (raise "No such middleware to remove: #{target.inspect}")
|
||||
end
|
||||
|
||||
|
@ -43,15 +43,15 @@ def test_delete_works
|
||||
end
|
||||
end
|
||||
|
||||
test "remove deletes the middleware" do
|
||||
test "delete! deletes the middleware" do
|
||||
assert_difference "@stack.size", -1 do
|
||||
@stack.remove FooMiddleware
|
||||
@stack.delete! FooMiddleware
|
||||
end
|
||||
end
|
||||
|
||||
test "remove requires the middleware to be in the stack" do
|
||||
test "delete! requires the middleware to be in the stack" do
|
||||
assert_raises RuntimeError do
|
||||
@stack.remove BazMiddleware
|
||||
@stack.delete! BazMiddleware
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -205,6 +205,13 @@ And to remove browser related middleware,
|
||||
config.middleware.delete Rack::MethodOverride
|
||||
```
|
||||
|
||||
If you want an error to be raised when you try to delete a non-existent item, use `delete!` instead.
|
||||
|
||||
```ruby
|
||||
# config/application.rb
|
||||
config.middleware.delete! ActionDispatch::Executor
|
||||
```
|
||||
|
||||
### Internal Middleware Stack
|
||||
|
||||
Much of Action Controller's functionality is implemented as Middlewares. The following list explains the purpose of each of them:
|
||||
|
Loading…
Reference in New Issue
Block a user