Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2012 20:15
Show Gist options
  • Select an option

  • Save anonymous/4348184 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/4348184 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Dec 20, 2012.
    3 changes: 3 additions & 0 deletions no_url_help.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    pull_response = RestCall.get("/repos/bob/rails8/pulls")
    issue_response = RestCall.get("/repos/bob/rails8/issues/#{response.first['issue']}")
    # either of these might 404
    10 changes: 10 additions & 0 deletions with_url_help.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    pull_response = RestCall.get("/repos/bob/rails8/pulls")
    issue_response = RestCall.get(pull_response.first["issue_url"]) # => oops, what if response is empty?

    if pull_response.present?
    issue_response = RestCall.get(pull_response.first["issue_url"]) # => oops, what if response issue_url isn't there?
    end

    if pull_response.present? && pull_response.first["issue_url"].present?
    issue_response = RestCall.get(pull_response.first["issue_url"]) # OK!
    end