Module: Hub::GitHubAPI::HttpMethods::ResponseMethods
- Defined in:
- lib/hub/github_api.rb
Overview
Decorator for Net::HTTPResponse
Instance Method Summary collapse
- #data ⇒ Object
- #data? ⇒ Boolean
- #error_message ⇒ Object
- #error_message? ⇒ Boolean
- #error_sentences ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
Instance Method Details
#data ⇒ Object
120 |
# File 'lib/hub/github_api.rb', line 120 def data() @data ||= JSON.parse(body) end |
#data? ⇒ Boolean
119 |
# File 'lib/hub/github_api.rb', line 119 def data?() content_type =~ /\bjson\b/ end |
#error_message ⇒ Object
122 |
# File 'lib/hub/github_api.rb', line 122 def () error_sentences || data['message'] end |
#error_message? ⇒ Boolean
121 |
# File 'lib/hub/github_api.rb', line 121 def () data? and data['errors'] || data['message'] end |
#error_sentences ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/hub/github_api.rb', line 124 def error_sentences data['errors'].map do |err| case err['code'] when 'custom' then err['message'] when 'missing_field' then "field '%s' is missing" % err['field'] end end.compact if data['errors'] end |
#status ⇒ Object
118 |
# File 'lib/hub/github_api.rb', line 118 def status() code.to_i end |
#success? ⇒ Boolean
123 |
# File 'lib/hub/github_api.rb', line 123 def success?() Net::HTTPSuccess === self end |