Sha256: df78ad3cb83f77a8ad6cfa4bc945c5e1ca67b75366c5f646e646a62bfa6251c3

Contents?: true

Size: 934 Bytes

Versions: 5

Compression:

Stored size: 934 Bytes

Contents

module ActiveFedora
  class CleanConnection < SimpleDelegator
    def get(*args)
      result = __getobj__.get(*args) do |req|
        prefer_headers = Ldp::PreferHeaders.new(req.headers["Prefer"])
        prefer_headers.omit = prefer_headers.omit | omit_uris
        req.headers["Prefer"] = prefer_headers.to_s
      end
      CleanResult.new(result)
    end

    private

    def omit_uris
      [
        ::RDF::Vocab::Fcrepo4.ServerManaged,
        ::RDF::Vocab::LDP.PreferContainment,
        ::RDF::Vocab::LDP.PreferEmptyContainer,
        ::RDF::Vocab::LDP.PreferMembership
      ]
    end

    class CleanResult < SimpleDelegator
      def graph
        @graph ||= clean_graph
      end

      private

      def clean_graph
        __getobj__.graph.delete(has_model_query)
        __getobj__.graph
      end

      def has_model_query
        [nil, ActiveFedora::RDF::Fcrepo::Model.hasModel, nil]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
active-fedora-9.5.0 lib/active_fedora/clean_connection.rb
active-fedora-9.4.3 lib/active_fedora/clean_connection.rb
active-fedora-9.4.2 lib/active_fedora/clean_connection.rb
active-fedora-9.4.1 lib/active_fedora/clean_connection.rb
active-fedora-9.4.0 lib/active_fedora/clean_connection.rb