Class: SpecForge::HTTP::Verb
- Inherits:
-
Object
- Object
- SpecForge::HTTP::Verb
- Defined in:
- lib/spec_forge/http/verb.rb
Overview
Represents an HTTP verb (method)
This class provides a type-safe way to work with HTTP methods, with predefined constants for common verbs like GET, POST, etc.
Defined Under Namespace
Classes: Delete, Get, Patch, Post, Put
Constant Summary collapse
- DELETE =
A predefined DELETE verb instance for HTTP method usage
Delete.new
- GET =
A predefined GET verb instance for HTTP method usage
Get.new
- PATCH =
A predefined PATCH verb instance for HTTP method usage
Patch.new
- POST =
A predefined POST verb instance for HTTP method usage
Post.new
- PUT =
A predefined PUT verb instance for HTTP method usage
Put.new
- VERBS =
All HTTP verbs as a lookup hash
{ delete: DELETE, get: GET, patch: PATCH, post: POST, put: PUT }.freeze
Class Method Summary collapse
-
.from(name) ⇒ Verb?
Retrieves the corresponding Verb instance based on the provided HTTP name.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Returns if this Verb name matches another Verb's name, or the name as a String or Symbol.
-
#delete? ⇒ Boolean
Returns if this Verb is a DELETE.
-
#get? ⇒ Boolean
Returns if this Verb is a GET.
-
#patch? ⇒ Boolean
Returns if this Verb is a PATCH.
-
#post? ⇒ Boolean
Returns if this Verb is a POST.
-
#put? ⇒ Boolean
Returns if this Verb is a PUT.
Class Method Details
Instance Method Details
#==(other) ⇒ Boolean
Returns if this Verb name matches another Verb's name, or the name as a String or Symbol
140 141 142 143 144 145 146 147 148 149 |
# File 'lib/spec_forge/http/verb.rb', line 140 def ==(other) case other when Verb name == other.name when String, Symbol self == self.class.from(other) else false end end |
#delete? ⇒ Boolean
Returns if this Verb is a DELETE
160 161 162 |
# File 'lib/spec_forge/http/verb.rb', line 160 def delete? name == "DELETE" end |
#get? ⇒ Boolean
Returns if this Verb is a GET
169 170 171 |
# File 'lib/spec_forge/http/verb.rb', line 169 def get? name == "GET" end |
#patch? ⇒ Boolean
Returns if this Verb is a PATCH
178 179 180 |
# File 'lib/spec_forge/http/verb.rb', line 178 def patch? name == "PATCH" end |
#post? ⇒ Boolean
Returns if this Verb is a POST
187 188 189 |
# File 'lib/spec_forge/http/verb.rb', line 187 def post? name == "POST" end |
#put? ⇒ Boolean
Returns if this Verb is a PUT
196 197 198 |
# File 'lib/spec_forge/http/verb.rb', line 196 def put? name == "PUT" end |