Skip to content

Commit 1c32d47

Browse files
committed
Remove < Methods from Middleware.
1 parent 075c3d0 commit 1c32d47

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

lib/protocol/http/methods.rb

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,34 @@
55

66
module Protocol
77
module HTTP
8-
# All supported HTTP methods
8+
# All supported HTTP methods, as outlined by <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods>.
99
class Methods
10+
# The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
1011
GET = 'GET'
12+
13+
# The HEAD method asks for a response identical to a GET request, but without the response body.
14+
HEAD = 'HEAD'
15+
16+
# The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.
1117
POST = 'POST'
18+
19+
# The PUT method replaces all current representations of the target resource with the request payload.
1220
PUT = 'PUT'
13-
PATCH = 'PATCH'
21+
22+
# The DELETE method deletes the specified resource.
1423
DELETE = 'DELETE'
15-
HEAD = 'HEAD'
24+
25+
# The CONNECT method establishes a tunnel to the server identified by the target resource.
26+
CONNECT = 'CONNECT'
27+
28+
# The OPTIONS method describes the communication options for the target resource.
1629
OPTIONS = 'OPTIONS'
17-
LINK = 'LINK'
18-
UNLINK = 'UNLINK'
30+
31+
# The TRACE method performs a message loop-back test along the path to the target resource.
1932
TRACE = 'TRACE'
20-
CONNECT = 'CONNECT'
33+
34+
# The PATCH method applies partial modifications to a resource.
35+
PATCH = 'PATCH'
2136

2237
def self.valid?(name)
2338
const_defined?(name)
@@ -26,13 +41,18 @@ def self.valid?(name)
2641
return false
2742
end
2843

44+
# Enumerate all HTTP methods.
45+
# @yields {|name, value| ...}
46+
# @parameter name [Symbol] The name of the method, e.g. `:GET`.
47+
# @parameter value [String] The value of the method, e.g. `"GET"`.
2948
def self.each
49+
return to_enum(:each) unless block_given?
50+
3051
constants.each do |name|
3152
yield name, const_get(name)
3253
end
3354
end
3455

35-
# Use Methods.constants to get all constants.
3656
self.each do |name, value|
3757
define_method(name.downcase) do |location, headers = nil, body = nil|
3858
self.call(

lib/protocol/http/middleware.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module Protocol
1212
module HTTP
13-
class Middleware < Methods
13+
class Middleware
1414
# Convert a block to a middleware delegate.
1515
def self.for(&block)
1616
def block.close

0 commit comments

Comments
 (0)