module Disqussion::Request
Defines HTTP request methods
Public Instance Methods
get(path, options={}, raw=false)
click to toggle source
Perform an HTTP GET request
# File lib/disqussion/request.rb, line 5 def get(path, options={}, raw=false) request(:get, path, options, raw) end
post(path, options={}, raw=false)
click to toggle source
Perform an HTTP POST request
# File lib/disqussion/request.rb, line 10 def post(path, options={}, raw=false) request(:post, path, options, raw) end
Private Instance Methods
formatted_path(path)
click to toggle source
# File lib/disqussion/request.rb, line 34 def formatted_path(path) [path, format].compact.join('.') end
request(method, path, options, raw=false)
click to toggle source
Perform an HTTP request
# File lib/disqussion/request.rb, line 17 def request(method, path, options, raw=false) # identify our request # @see: http://docs.disqus.com/help/52/ options ||= {} options.merge!(:api_secret => self.api_secret) unless options.has_key?(:api_secret) response = connection(raw).send(method) do |request| case method when :get request.url(formatted_path(path), options) when :post request.path = formatted_path(path) request.body = options unless options.empty? end end raw ? response : response.body end