class Qa::LDF::Authority

A Linked Data Fragments-based authority. Access linked data resources through a caching server.

@see LinkedDataFragments::CacheServer

Constants

DEFAULT_CLIENT

The default linked data fragments client

DEFAULT_DATASET_NAME

The default linked data fragments client

DEFAULT_MAPPER

The default mapper

DEFAULT_SEARCH_SERVICE

The default search service

Attributes

client[W]

@!attribute [rw] client

@return [Client]

@!attribute [rw] dataset

@return [Symbol] A dataset name (e.g. :lcsh)

@!attribute [rw] mapper

@return [Mapper]

@!attribute [rw] search_service

@return [#search]
dataset[W]

@!attribute [rw] client

@return [Client]

@!attribute [rw] dataset

@return [Symbol] A dataset name (e.g. :lcsh)

@!attribute [rw] mapper

@return [Mapper]

@!attribute [rw] search_service

@return [#search]
mapper[W]

@!attribute [rw] client

@return [Client]

@!attribute [rw] dataset

@return [Symbol] A dataset name (e.g. :lcsh)

@!attribute [rw] mapper

@return [Mapper]

@!attribute [rw] search_service

@return [#search]
search_service[W]

@!attribute [rw] client

@return [Client]

@!attribute [rw] dataset

@return [Symbol] A dataset name (e.g. :lcsh)

@!attribute [rw] mapper

@return [Mapper]

@!attribute [rw] search_service

@return [#search]

Public Class Methods

for(namespace:) click to toggle source

Gives an authority class for the given namespace.

@param namespace [#to_s] a URI-like namespace string

@return [Authority]

# File lib/qa/ldf/authority.rb, line 38
def for(namespace:)
  @@namespace_map.fetch(namespace.to_s) { self }.new
end
namespace() click to toggle source

@return [String] gives an empty string for no namespace,

{#for_namespace} returns self in this case
# File lib/qa/ldf/authority.rb, line 45
def namespace
  ''
end
namespaces() click to toggle source

@return [Enumerable<String>]

# File lib/qa/ldf/authority.rb, line 51
def namespaces
  @@namespace_map.keys
end
new(*) { |self| ... } click to toggle source

@yieldparam authority [Authority] self

Calls superclass method
# File lib/qa/ldf/authority.rb, line 88
def initialize(*)
  super
  yield self if block_given?
end
register_namespace(namespace:, klass:) click to toggle source

Registers a namespace/class pair.

@param namespace [#to_s] a URI-like namespace string @param klass [Class] an authority class

@return [void]

# File lib/qa/ldf/authority.rb, line 62
def register_namespace(namespace:, klass:)
  @@namespace_map[namespace.to_s] = klass
end
reset_namespaces() click to toggle source

Resets the namespaces

@return [void]

# File lib/qa/ldf/authority.rb, line 70
def reset_namespaces
  @@namespace_map = {}
end

Public Instance Methods

all() click to toggle source

@see Qa::Authorities::Base#all

# File lib/qa/ldf/authority.rb, line 95
def all
  []
end
client() click to toggle source

@return [Qa::LDF::Client]

# File lib/qa/ldf/authority.rb, line 132
def client
  @client ||= self.class::DEFAULT_CLIENT.new
end
dataset() click to toggle source

@return [Symbol]

# File lib/qa/ldf/authority.rb, line 138
def dataset
  @dataset ||= self.class::DEFAULT_DATASET_NAME
end
find(id) click to toggle source

Retrieves the given resource's JSON respresentation from the cache server.

The resource is retrieved through the client given by `#client`, and mapped to JSON using `#mapper`.

@see Qa::Authorities::Base#find @see Qa::LDF::Client#get

# File lib/qa/ldf/authority.rb, line 108
def find(id)
  mapper.map_resource(id, graph(id))
end
graph(uri) click to toggle source

@param uri [RDF::URI] @return [RDF::Enumerable]

# File lib/qa/ldf/authority.rb, line 115
def graph(uri)
  client.get(uri: uri, dataset: dataset)
end
mapper() click to toggle source

@return [JsonMapper]

# File lib/qa/ldf/authority.rb, line 144
def mapper
  @mapper ||= self.class::DEFAULT_MAPPER.new
end
search_service() click to toggle source

@return [#search]

# File lib/qa/ldf/authority.rb, line 150
def search_service
  @search_service ||= self.class::DEFAULT_SEARCH_SERVICE.new
end