Created
December 17, 2014 22:46
-
-
Save yurinnick/d535818a48588932d266 to your computer and use it in GitHub Desktop.
Method generation
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
%w(get post put delete).each do |http_method| | |
define_singleton_method(http_method.to_sym) do |path, *args| | |
RestClient::Resource.new("#{Qubell.configuration.endpoint}/api/" \ | |
"#{Qubell.configuration.api_version}#{path}", | |
Qubell.configuration.username, | |
Qubell.configuration.password) | |
.send(http_method.to_sym, *args) do |response| | |
handle_response(response) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment