Sha256: 758933abfb8976e1226afe8274b947018f8b33a90a2d9cfb60e0fca6141e4690

Contents?: true

Size: 565 Bytes

Versions: 1

Compression:

Stored size: 565 Bytes

Contents

require 'faraday'
require 'faraday_middleware'

module MLB
  # @private
  class Request
    # Perform an HTTP GET request
    def self.get(path, options={}, raw=false)
      response = connection(raw).get do |request|
        request.url(path, options)
      end
      raw ? response : response.body
    end

    private

    def self.connection(raw=false)
      Faraday.new(url: 'http://api.freebase.com') do |connection|
        connection.use FaradayMiddleware::ParseJson unless raw
        connection.adapter Faraday.default_adapter
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mlb-0.6.2 lib/mlb/request.rb