module Rester::Client::Adapters

Constants

DEFAULT_OPTS

Default connection options.

Public Class Methods

connect(service, opts={}) click to toggle source

Returns an instance of the appropriate adapter that is connected to the service.

# File lib/rester/client/adapters.rb, line 26
def connect(service, opts={})
  klass = list.find { |a| a.can_connect_to?(service) }
  fail "unable to find an adapter for #{service.inspect}" unless klass
  klass.new(service, opts)
end
extract_opts(opts={}) click to toggle source

Given a hash, extracts the options that are part of the adapter interface.

# File lib/rester/client/adapters.rb, line 35
def extract_opts(opts={})
  sel = proc { |k, _| DEFAULT_OPTS.keys.include?(k) }
  DEFAULT_OPTS.merge(opts.select(&sel).tap { opts.delete_if(&sel) })
end
list() click to toggle source

Returns a list of available adapter classes.

# File lib/rester/client/adapters.rb, line 18
def list
  constants.map { |c| const_get(c) }
    .select { |c| c.is_a?(Class) && c < Adapter }
end