Class: Embedly::Request::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/embedly/request/base.rb

Overview

Interface to create custom requesters

The class

If you want to define a custom requester, you should create a class that inherits from this base class.

The class should respond to get that receives the uri object and the api options. The method should perform a get request to Embedly api and return a response object:

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

For more examples, see embedly/requests/*.rb files

Adding to configuration

Make sure to add your class to embedly requesters, like the following:

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

This way you can configure the API to use your custom request object:

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

Direct Known Subclasses

NetHTTP::Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Base

Receives the current api object



40
41
42
# File 'lib/embedly/request/base.rb', line 40

def initialize(api)
  @api = api
end

Instance Attribute Details

#apiObject

:nodoc:



37
38
39
# File 'lib/embedly/request/base.rb', line 37

def api
  @api
end

Instance Method Details

#get(uri, options = {}) ⇒ Object

Implement this method

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/embedly/request/base.rb', line 45

def get(uri, options = {})
  raise NotImplementedError
end