Module: Wrest::HttpCodes

Included in:
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

#accepted?Boolean

Returns:

  • (Boolean)


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

def accepted?
  code.to_i == 202
end

#bad_request?Boolean

Returns:

  • (Boolean)


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

def bad_request?
  code.to_i == 400
end

#created?Boolean

Returns:

  • (Boolean)


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

def created?
  code.to_i == 201
end

#forbidden?Boolean

Returns:

  • (Boolean)


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

def forbidden?
  code.to_i == 403
end

#found?Boolean

Returns:

  • (Boolean)


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

def found?
  code.to_i == 302
end

#internal_server_error?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/wrest/http_codes.rb', line 79

def internal_server_error?
  code.to_i == 500
end

#method_not_allowed?Boolean

Returns:

  • (Boolean)


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

def method_not_allowed?
  code.to_i == 405
end

#moved_permanently?Boolean

Returns:

  • (Boolean)


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

def moved_permanently?
  code.to_i == 301
end

#no_content?Boolean

Returns:

  • (Boolean)


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

def no_content?
  code.to_i == 204
end

#not_acceptable?Boolean

Returns:

  • (Boolean)


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

def not_acceptable?
  code.to_i == 406
end

#not_found?Boolean

Returns:

  • (Boolean)


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

def not_found?
  code.to_i == 404
end

#not_modified?Boolean

Returns:

  • (Boolean)


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

def not_modified?
  code.to_i == 304
end

#ok?Boolean

Returns:

  • (Boolean)


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

def ok?
  code.to_i == 200
end

#see_other?Boolean

Returns:

  • (Boolean)


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

def see_other?
  code.to_i == 303
end

#temporary_redirect?Boolean

Returns:

  • (Boolean)


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

def temporary_redirect?
  code.to_i == 307
end

#unauthorized?Boolean

Returns:

  • (Boolean)


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

def unauthorized?
  code.to_i == 401
end

#unprocessable_entity?Boolean

Returns:

  • (Boolean)


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

def unprocessable_entity?
  code.to_i == 422
end