Module: PartyResource::Connector

Defined in:
lib/party_resource/connector.rb,
lib/party_resource/connector/base.rb

Defined Under Namespace

Classes: Base, Repository

Class Method Summary collapse

Class Method Details

.add(name, options) ⇒ Object

Add a new named connector

Examples:

PartyResource::Connector.add(:other_connector, {:base_uri => 'http://otherserver/'})
PartyResource::Connector.add(:my_connector, {:base_uri => 'http://myserver/path', :username => 'fred', :password => 'pass', :default => true})

Parameters:

  • name (Symbol)

    Name for new connector

  • options (Hash)

Options Hash (options):

  • :base_uri (String) — default: ''

    URI to append to all routes using this connector

  • :username (String)

    HTTP basic auth username

  • :password (String)

    HTTP basic auth password

  • :default (Boolean) — default: false

    Set this connector as the default



26
27
28
# File 'lib/party_resource/connector.rb', line 26

def add(name, options)
  repository.new_connector(name, options)
end

.lookup(name) ⇒ Connector::Base

Find connector by name

Returns:

Raises:



7
8
9
10
11
12
# File 'lib/party_resource/connector.rb', line 7

def lookup(name)
  name ||= repository.default
  connector = repository.connectors[name]
  raise Exceptions::NoConnector.new(name) if connector.nil?
  connector
end

.repositoryObject



30
31
32
# File 'lib/party_resource/connector.rb', line 30

def repository
  @repository ||= Repository.new
end