Sha256: 3b7c6dec8d34d5b5d3505848ee83256261e3ed720061a621e415770204fad080
Contents?: true
Size: 1.38 KB
Versions: 5
Compression:
Stored size: 1.38 KB
Contents
require 'berkeley_library/util' module BerkeleyLibrary module Holdings module HathiTrust module Config include BerkeleyLibrary::Util::URIs ENV_HATHITRUST_BASE_URL = 'LIT_HATHITRUST_BASE_URL'.freeze # The default HathiTrust base URL, if ENV_HATHITRUST_BASE_URL is not set. DEFAULT_HATHITRUST_BASE_URL = 'https://catalog.hathitrust.org/api/'.freeze class << self include Config end def base_uri @base_uri ||= default_hathitrust_base_uri end def base_uri=(value) @base_uri = uri_or_nil(value) end private def reset! remove_instance_variable(:@base_uri) if instance_variable_defined?(:@base_uri) end def default_hathitrust_base_uri uri_or_nil(default_hathitrust_base_url) end def default_hathitrust_base_url ENV[ENV_HATHITRUST_BASE_URL] || rails_hathitrust_base_url || DEFAULT_HATHITRUST_BASE_URL end def rails_hathitrust_base_url return unless (rails_config = self.rails_config) return unless rails_config.respond_to?(:hathitrust_base_url) rails_config.hathitrust_base_url end def rails_config return unless defined?(Rails) return unless (app = Rails.application) app.config end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems