Module: Love
- Defined in:
- lib/love.rb
Overview
Love is a small Ruby library to interact with the Tender REST API. The main object to work with is Client, which is returned by calling Love.connect.
It is dedicated to the awesome work Aaeron Patterson has been giving to the Ruby community.
Defined Under Namespace
Modules: ResourceURI Classes: Client, Exception, NotFound, Unauthorized
Constant Summary collapse
- VERSION =
The current gem version. Will be updated automatically by the gem release script.
"0.0.5"
Class Method Summary collapse
-
.connect(site, api_key, options = {}, &block) ⇒ Object
Connects to the Tender API to access a site using an API key.
Instance Method Summary collapse
-
#logger ⇒ Logger
HTTP connectivity somewhere.
Class Method Details
.connect(site, api_key, options = {}) {|Love::Client| ... } ⇒ Object .connect(site, api_key, options = {}) ⇒ Love::Client
Connects to the Tender API to access a site using an API key.
This method doesn’t do any communication yet with the Tender API, it will only set up the client with the provided credentials and options.
By default, the client will use a new connection for every request. It can also open a persistent connection if you want to do multiple requests, by passing :persistent => true
as option. In this case, you need to call Love::Client#close_connection when you are done with your session. You can also provide a block to this method which will automatically open up a persistent connection and close it at the end of the block.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/love.rb', line 52 def self.connect(site, api_key, = {}, &block) if block_given? begin client = Love::Client.new(site, api_key, .merge(:persistent => true)) block.call(client) ensure client.close_connection end else Love::Client.new(site, api_key, ) end end |
Instance Method Details
#logger ⇒ Logger
HTTP connectivity somewhere.
67 |
# File 'lib/love.rb', line 67 mattr_accessor :logger |