Skip to content

Add request adapters#11

Merged
dokipen merged 5 commits intoembedly:masterfrom
felipeelias:adapters
Jun 17, 2013
Merged

Add request adapters#11
dokipen merged 5 commits intoembedly:masterfrom
felipeelias:adapters

Conversation

@felipeelias
Copy link
Contributor

This introduces a new module called Request. The idea is to remove duplication in the API class by moving request related methods to their own class and allow the user to create its own requester class:

class MyRequester < Embedly::Request::Base
  def get(uri, options = {})
    # performs the request
  end
end

This class is responsible to make the request. The user can register the new class in configuration and use it as follow:

Embedly.configuration.add_requester :my_requester do |api|
  MyRequester.new(api)
end

Embedly.configure do |config|
  config.request_with :my_requester
end

After that, all api requests are made with the new request class. This allows users to user faraday gem for example, without messing up with the api class.

As an example, you can check that the _do_typhoeus_call method was moved to Embedly::Typhoeus::Request.

Basically they're wrappers around the related library, and the
idea is to make easy the switch and customization of new libraries
- tweaks in api, to make use of current requester class
- adds related methods to configuration class, to make easy
  the switch between requesters
- fix command line
@dokipen dokipen merged commit 044a2bb into embedly:master Jun 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants