Skip to content

Instantly share code, notes, and snippets.

@Dazzla
Last active January 4, 2016 00:19
Show Gist options
  • Save Dazzla/8540949 to your computer and use it in GitHub Desktop.
Save Dazzla/8540949 to your computer and use it in GitHub Desktop.
def self.put_json_to_url input_url, json_body
safely_request{RestClient.put(input_url, json_body, :content_type => 'application/json')}
end
def safely_request(&block)
begin
@response = parse_response(block.call)
rescue Exception => e
raise e.response
end
parse_response(@response)
end
@Dazzla
Copy link
Author

Dazzla commented Jan 21, 2014

Just updated. It strikes me that it could be refactored to be even shorter using eval(), but let's leave it at this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment