Module: Wrest::HttpCodes
- Included in:
- Curl::Response, Native::Response
- Defined in:
- lib/wrest/http_codes.rb
Overview
Contains convenience methods to check HTTP response codes
Instance Method Summary (collapse)
- - (Boolean) accepted?
- - (Boolean) bad_request?
- - (Boolean) created?
- - (Boolean) forbidden?
- - (Boolean) found?
- - (Boolean) internal_server_error?
- - (Boolean) method_not_allowed?
- - (Boolean) moved_permanently?
- - (Boolean) no_content?
- - (Boolean) not_acceptable?
- - (Boolean) not_found?
- - (Boolean) not_modified?
- - (Boolean) ok?
- - (Boolean) see_other?
- - (Boolean) temporary_redirect?
- - (Boolean) unauthorized?
- - (Boolean) unprocessable_entity?
Instance Method Details
- (Boolean) accepted?
22 23 24 |
# File 'lib/wrest/http_codes.rb', line 22 def accepted? self.code.to_i == 202 end |
- (Boolean) bad_request?
50 51 52 |
# File 'lib/wrest/http_codes.rb', line 50 def bad_request? self.code.to_i == 400 end |
- (Boolean) created?
18 19 20 |
# File 'lib/wrest/http_codes.rb', line 18 def created? self.code.to_i == 201 end |
- (Boolean) forbidden?
58 59 60 |
# File 'lib/wrest/http_codes.rb', line 58 def forbidden? self.code.to_i == 403 end |
- (Boolean) found?
34 35 36 |
# File 'lib/wrest/http_codes.rb', line 34 def found? self.code.to_i == 302 end |
- (Boolean) internal_server_error?
78 79 80 |
# File 'lib/wrest/http_codes.rb', line 78 def internal_server_error? self.code.to_i == 500 end |
- (Boolean) method_not_allowed?
66 67 68 |
# File 'lib/wrest/http_codes.rb', line 66 def method_not_allowed? self.code.to_i == 405 end |
- (Boolean) moved_permanently?
30 31 32 |
# File 'lib/wrest/http_codes.rb', line 30 def moved_permanently? self.code.to_i == 301 end |
- (Boolean) no_content?
26 27 28 |
# File 'lib/wrest/http_codes.rb', line 26 def no_content? self.code.to_i == 204 end |
- (Boolean) not_acceptable?
70 71 72 |
# File 'lib/wrest/http_codes.rb', line 70 def not_acceptable? self.code.to_i == 406 end |
- (Boolean) not_found?
62 63 64 |
# File 'lib/wrest/http_codes.rb', line 62 def not_found? self.code.to_i == 404 end |
- (Boolean) not_modified?
42 43 44 |
# File 'lib/wrest/http_codes.rb', line 42 def not_modified? self.code.to_i == 304 end |
- (Boolean) ok?
14 15 16 |
# File 'lib/wrest/http_codes.rb', line 14 def ok? self.code.to_i == 200 end |
- (Boolean) see_other?
38 39 40 |
# File 'lib/wrest/http_codes.rb', line 38 def see_other? self.code.to_i == 303 end |
- (Boolean) temporary_redirect?
46 47 48 |
# File 'lib/wrest/http_codes.rb', line 46 def temporary_redirect? self.code.to_i == 307 end |
- (Boolean) unauthorized?
54 55 56 |
# File 'lib/wrest/http_codes.rb', line 54 def self.code.to_i == 401 end |
- (Boolean) unprocessable_entity?
74 75 76 |
# File 'lib/wrest/http_codes.rb', line 74 def unprocessable_entity? self.code.to_i == 422 end |