Sha256: 0363446e38b399d001eecdd559401a8820d883d488d8db4ba9b9e3038b7355a1

Contents?: true

Size: 560 Bytes

Versions: 1

Compression:

Stored size: 560 Bytes

Contents

require 'faraday'
require 'mlb/response/parse_json'

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 |builder|
        builder.use MLB::Response::ParseJson unless raw
        builder.adapter Faraday.default_adapter
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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