Class: Hydra::ContentNegotiation::FedoraUriReplacer

Inherits:
Object
  • Object
show all
Defined in:
app/models/hydra/content_negotiation/fedora_uri_replacer.rb

Overview

Replaces Fedora URIs in a graph with a Hydra-configured alternative.

Instance Method Summary collapse

Constructor Details

#initialize(fedora_base_uri, graph, replacer) ⇒ FedoraUriReplacer

Returns a new instance of FedoraUriReplacer.

Parameters:

  • fedora_base_uri (String)

    the internal Fedora base uri

  • graph (RDF::Graph)

    the original graph that needs URIs replaced

  • replacer (#call)

    a function that is called with id and graph and returns a string representation of the new uri.



7
8
9
10
11
# File 'app/models/hydra/content_negotiation/fedora_uri_replacer.rb', line 7

def initialize(fedora_base_uri, graph, replacer)
  @fedora_base_uri = fedora_base_uri
  @graph = graph
  @replacer = replacer
end

Instance Method Details

#runObject



13
14
15
# File 'app/models/hydra/content_negotiation/fedora_uri_replacer.rb', line 13

def run
  RDF::Graph.new.insert(*replaced_objects)
end