Sha256: 24d616d064280155051b7c5dc3a94d11d55228ae71aed208e72620d1e1bbc1a8

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

require 'faraday'

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::Connection.new(:url => 'http://api.freebase.com') do |connection|
        connection.use Faraday::Response::Yajl 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.4.0 lib/mlb/request.rb