Sha256: 49ecf5dc6816dd2ea63f4c2c9d8d11be525040629a91e1c324367ed1fb747266
Contents?: true
Size: 875 Bytes
Versions: 3
Compression:
Stored size: 875 Bytes
Contents
module JsonApiClient class Connection attr_reader :faraday def initialize(site) @faraday = Faraday.new(site) do |builder| builder.request :url_encoded builder.use Middleware::JsonRequest builder.use Middleware::Status builder.use Middleware::ParseJson builder.adapter Faraday.default_adapter end yield(self) if block_given? end # insert middleware before ParseJson - middleware executed in reverse order - # inserted middleware will run after json parsed def use(middleware, *args, &block) faraday.builder.insert_before(Middleware::ParseJson, middleware, *args, &block) end def delete(middleware) faraday.builder.delete(middleware) end def execute(query) faraday.send(query.request_method, query.path, query.params, query.headers) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
json_api_client-0.2.4 | lib/json_api_client/connection.rb |
json_api_client-0.2.3 | lib/json_api_client/connection.rb |
json_api_client-0.2.2 | lib/json_api_client/connection.rb |