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)

Instance Method Details

- (Boolean) accepted?

Returns:

  • (Boolean)


22
23
24
# File 'lib/wrest/http_codes.rb', line 22

def accepted?
  self.code.to_i == 202
end

- (Boolean) bad_request?

Returns:

  • (Boolean)


50
51
52
# File 'lib/wrest/http_codes.rb', line 50

def bad_request?
  self.code.to_i == 400
end

- (Boolean) created?

Returns:

  • (Boolean)


18
19
20
# File 'lib/wrest/http_codes.rb', line 18

def created?
  self.code.to_i == 201
end

- (Boolean) forbidden?

Returns:

  • (Boolean)


58
59
60
# File 'lib/wrest/http_codes.rb', line 58

def forbidden?
  self.code.to_i == 403
end

- (Boolean) found?

Returns:

  • (Boolean)


34
35
36
# File 'lib/wrest/http_codes.rb', line 34

def found?
  self.code.to_i == 302
end

- (Boolean) internal_server_error?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


66
67
68
# File 'lib/wrest/http_codes.rb', line 66

def method_not_allowed?
  self.code.to_i == 405
end

- (Boolean) moved_permanently?

Returns:

  • (Boolean)


30
31
32
# File 'lib/wrest/http_codes.rb', line 30

def moved_permanently?
  self.code.to_i == 301
end

- (Boolean) no_content?

Returns:

  • (Boolean)


26
27
28
# File 'lib/wrest/http_codes.rb', line 26

def no_content?
  self.code.to_i == 204
end

- (Boolean) not_acceptable?

Returns:

  • (Boolean)


70
71
72
# File 'lib/wrest/http_codes.rb', line 70

def not_acceptable?
  self.code.to_i == 406
end

- (Boolean) not_found?

Returns:

  • (Boolean)


62
63
64
# File 'lib/wrest/http_codes.rb', line 62

def not_found?
  self.code.to_i == 404
end

- (Boolean) not_modified?

Returns:

  • (Boolean)


42
43
44
# File 'lib/wrest/http_codes.rb', line 42

def not_modified?
  self.code.to_i == 304
end

- (Boolean) ok?

Returns:

  • (Boolean)


14
15
16
# File 'lib/wrest/http_codes.rb', line 14

def ok?
  self.code.to_i == 200
end

- (Boolean) see_other?

Returns:

  • (Boolean)


38
39
40
# File 'lib/wrest/http_codes.rb', line 38

def see_other?
  self.code.to_i == 303
end

- (Boolean) temporary_redirect?

Returns:

  • (Boolean)


46
47
48
# File 'lib/wrest/http_codes.rb', line 46

def temporary_redirect?
  self.code.to_i == 307
end

- (Boolean) unauthorized?

Returns:

  • (Boolean)


54
55
56
# File 'lib/wrest/http_codes.rb', line 54

def unauthorized?
  self.code.to_i == 401
end

- (Boolean) unprocessable_entity?

Returns:

  • (Boolean)


74
75
76
# File 'lib/wrest/http_codes.rb', line 74

def unprocessable_entity?
  self.code.to_i == 422
end