module OpenWeather::Request
Public Instance Methods
delete(path, options = {})
click to toggle source
# File lib/open_weather/request.rb, line 17 def delete(path, options = {}) request(:delete, path, options) end
get(path, options = {})
click to toggle source
# File lib/open_weather/request.rb, line 5 def get(path, options = {}) request(:get, path, options) end
post(path, options = {})
click to toggle source
# File lib/open_weather/request.rb, line 9 def post(path, options = {}) request(:post, path, options) end
put(path, options = {})
click to toggle source
# File lib/open_weather/request.rb, line 13 def put(path, options = {}) request(:put, path, options) end
Private Instance Methods
request(method, path, options)
click to toggle source
# File lib/open_weather/request.rb, line 23 def request(method, path, options) options = options.dup options[:appid] ||= api_key if api_key.present? options[:lang] ||= lang if lang.present? options[:units] ||= units if units.present? root = options.delete(:endpoint) || endpoint path = [root, path].join('/') response = connection.send(method) do |request| case method when :get, :delete request.url(path, options) when :post, :put request.path = path request.body = options unless options.empty? end request.options.merge!(options.delete(:request)) if options.key?(:request) end response.body end