Last active
January 4, 2016 00:19
-
-
Save Dazzla/8540949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.