Class: Embedly::Request::Base
- Inherits:
-
Object
- Object
- Embedly::Request::Base
- 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, = {})
# 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
Instance Attribute Summary collapse
-
#api ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#get(uri, options = {}) ⇒ Object
Implement this method.
-
#initialize(api) ⇒ Base
constructor
Receives the current api object.
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
#api ⇒ Object
: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
45 46 47 |
# File 'lib/embedly/request/base.rb', line 45 def get(uri, = {}) raise NotImplementedError end |