module GithubPivotalFlow::GitHubAPI::HttpMethods::ResponseMethods

Decorator for Net::HTTPResponse

Public Instance Methods

data() click to toggle source
# File lib/github_pivotal_flow/github_api.rb, line 81
def data() @data ||= MultiJson.load(body) end
data?() click to toggle source
# File lib/github_pivotal_flow/github_api.rb, line 80
def data?() content_type =~ /\bjson\b/ end
error_message() click to toggle source
# File lib/github_pivotal_flow/github_api.rb, line 83
def error_message() error_sentences || data['message'] end
error_message?() click to toggle source
# File lib/github_pivotal_flow/github_api.rb, line 82
def error_message?() data? and data['errors'] || data['message'] end
error_sentences() click to toggle source
# File lib/github_pivotal_flow/github_api.rb, line 85
def error_sentences
  data['errors'].map do |err|
    case err['code']
    when 'custom'        then err['message']
    when 'missing_field'
      %(Missing field: "%s") % err['field']
    when 'invalid'
      %(Invalid value for "%s": "%s") % [ err['field'], err['value'] ]
    when 'unauthorized'
      %(Not allowed to change field "%s") % err['field']
    end
  end.compact if data['errors']
end
status() click to toggle source
# File lib/github_pivotal_flow/github_api.rb, line 79
def status() code.to_i end
success?() click to toggle source
# File lib/github_pivotal_flow/github_api.rb, line 84
def success?() Net::HTTPSuccess === self end