Skip to content

Instantly share code, notes, and snippets.

@yurinnick
Created December 17, 2014 22:46
Show Gist options
  • Save yurinnick/d535818a48588932d266 to your computer and use it in GitHub Desktop.
Save yurinnick/d535818a48588932d266 to your computer and use it in GitHub Desktop.
Method generation
%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