Module: ActiveAnnotations::DocumentLoader

Defined in:
lib/active_annotations/document_loader.rb

Class Method Summary collapse

Class Method Details

.document_loaderObject



15
16
17
# File 'lib/active_annotations/document_loader.rb', line 15

def document_loader
  ENV['NO_RDF_CACHE'] == '1' ? JSON::LD::API.method(:documentLoader) : self.method(:local_document_loader)
end

.local_document_loader(url, options = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/active_annotations/document_loader.rb', line 4

def local_document_loader(url, options={}, &block)
  if RDF::URI(url) == RDF::URI(RDFAnnotation::CONTEXT_URI)
    remote_document = JSON::LD::API::RemoteDocument.new(File.read(File.expand_path('../oa.jsonld',__FILE__)), base: url)
    block_given? ? yield(remote_document) : remote_document
  else
    # :nocov:
    JSON::LD::API.documentLoader(url, options, &block)
    # :nocov:
  end
end