lib/protocol/http/methods.rb in protocol-http-0.4.1 vs lib/protocol/http/methods.rb in protocol-http-0.5.0

- old
+ new

@@ -21,21 +21,35 @@ # THE SOFTWARE. module Protocol module HTTP # HTTP method verbs - module Methods + class Methods GET = 'GET' POST = 'POST' PUT = 'PUT' PATCH = 'PATCH' DELETE = 'DELETE' HEAD = 'HEAD' OPTIONS = 'OPTIONS' LINK = 'LINK' UNLINK = 'UNLINK' TRACE = 'TRACE' + CONNECT = 'CONNECT' + def self.each + constants.each do |name| + yield name, const_get(name) + end + end + # Use Methods.constants to get all constants. + self.each do |name, verb| + define_method(verb.downcase) do |location, headers = [], body = nil| + self.call( + Request[verb, location.to_str, Headers[headers], body] + ) + end + end end end end