Sha256: eae48ffe5d70f659179f1f7cc957b10d596678434808632c4dad564e122e05ac
Contents?: true
Size: 1.46 KB
Versions: 6
Compression:
Stored size: 1.46 KB
Contents
module Vertebrae module Request METHODS = [:get, :post, :put, :delete, :patch] METHODS_WITH_BODIES = [ :post, :put, :patch ] def get_request(path, params={}, options={}) request(:get, path, params, options) end def patch_request(path, params={}, options={}) request(:patch, path, params, options) end def post_request(path, params={}, options={}) request(:post, path, params, options) end def put_request(path, params={}, options={}) request(:put, path, params, options) end def delete_request(path, params={}, options={}) request(:delete, path, params, options) end def request(method, path, params, options) # :nodoc: if !::Vertebrae::Request::METHODS.include?(method) raise ArgumentError, "unknown http method: #{method}" end path = connection.configuration.prefix + '/' + path ::Vertebrae::Base.logger.debug "EXECUTED: #{method} - #{path} with #{params} and #{options}" connection.connection.send(method) do |request| case method.to_sym when *(::Vertebrae::Request::METHODS - ::Vertebrae::Request::METHODS_WITH_BODIES) request.body = params.delete('data') if params.has_key?('data') request.url(path, params) when *::Vertebrae::Request::METHODS_WITH_BODIES request.path = path request.body = extract_data_from_params(params) unless params.empty? end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
vertebrae-0.2.8 | lib/request.rb |
vertebrae-0.2.7 | lib/request.rb |
vertebrae-0.2.6 | lib/request.rb |
vertebrae-0.2.5 | lib/request.rb |
vertebrae-0.2.4 | lib/request.rb |
vertebrae-0.2.2 | lib/request.rb |