Class: Hyrax::LocationService

Inherits:
Qa::Authorities::Geonames
  • Object
show all
Defined in:
app/services/hyrax/location_service.rb

Constant Summary collapse

CACHE_KEY_PREFIX =
'hyrax_geonames_label-v1-'
CACHE_EXPIRATION =
1.week

Instance Method Summary collapse

Instance Method Details

#full_label(uri) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'app/services/hyrax/location_service.rb', line 7

def full_label(uri)
  return if uri.blank?
  id = extract_id uri
  Rails.cache.fetch(cache_key(id), expires_in: CACHE_EXPIRATION) do
    label.call(find(id))
  end
rescue URI::InvalidURIError
  # Old data may be just a string, display it.
  uri
end