Sha256: c5bbee2b0064961b4069275dde6304f09aa64dab59eebcdee24ff398973a6ab9

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 Bytes

Contents

module Hydra
  module ContentNegotiation
    def self.extended(document)
      document.will_export_as(:nt, "application/n-triples")
      document.will_export_as(:jsonld, "application/json")
      document.will_export_as(:ttl, "text/turtle")
    end

    def export_as_nt
      clean_graph.dump(:ntriples)
    end

    def export_as_jsonld
      clean_graph.dump(:jsonld, :standard_prefixes => true)
    end

    def export_as_ttl
      clean_graph.dump(:ttl)
    end

    private

    def clean_graph
      @clean_graph ||= clean_graph_repository.find(id)
    end

    def clean_graph_repository
      CleanGraphRepository.new(connection)
    end

    def connection
      ActiveFedora.fedora.clean_connection
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-core-9.2.1 app/models/concerns/hydra/content_negotiation.rb
hydra-core-9.2.0 app/models/concerns/hydra/content_negotiation.rb
hydra-core-9.2.0.rc1 app/models/concerns/hydra/content_negotiation.rb