Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Merge ad1565f into e2b3c91
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Oct 23, 2019
2 parents e2b3c91 + ad1565f commit 6459500
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
26 changes: 6 additions & 20 deletions lib/dor/rest_resource_factory.rb
Expand Up @@ -5,34 +5,20 @@ module Dor
class RestResourceFactory
include Singleton

# @param type [Symbol] the type of connection to create (e.g. :fedora)
# @param url [String] the url to connect to
# @return [RestClient::Resource]
def self.create(type)
instance.create(type)
def self.create(url)
instance.create(url)
end

# @param type [Symbol] the type of connection to create (e.g. :fedora)
# @param url [String] the url to connect to
# @return [RestClient::Resource]
def create(type)
RestClient::Resource.new(url_for(type), connection_options)
def create(url)
RestClient::Resource.new(url, connection_options)
end

private

# @param type [Symbol] the type of connection to create (e.g. :fedora)
# @return [String] the url to connect to.
def url_for(type)
connection_configuration(type).url
end

# @param type [Symbol] the type of connection to create (e.g. :fedora)
# @return [#url] the configuration for the connection
def connection_configuration(type)
Dor::Config.fetch(type)
rescue KeyError
raise "ERROR: Unable to find a configuration for #{type}"
end

# @return [Hash] options for creating a RestClient::Resource
def connection_options
{}
Expand Down
2 changes: 1 addition & 1 deletion lib/dor/static_config/fedora_config.rb
Expand Up @@ -15,7 +15,7 @@ def configure(&block)
end

def client
CertificateAuthenticatedRestResourceFactory.create(:fedora)
CertificateAuthenticatedRestResourceFactory.create(url)
end

def url(new_value = nil)
Expand Down

0 comments on commit 6459500

Please sign in to comment.