Class: RDF::LDP::IndirectContainer
- Inherits:
-
DirectContainer
- Object
- Resource
- RDFSource
- Container
- DirectContainer
- RDF::LDP::IndirectContainer
- Defined in:
- lib/rdf/ldp/indirect_container.rb
Overview
An extension of ‘RDF::LDP::DirectContainer` implementing indirect containment. Adds the concept of an inserted content relation to the features of the direct container.
Clients MUST provide exactly one ‘ldp:insertedContentRelation` statement in each Indirect Container. If no `#inserted_content_relation` is given by the client, we default to `ldp:MemberSubject`. If more than one is present,
Attempts to POST resources without the appropriate content relation (or with more than one) to an Indirect Container will fail with ‘Not Acceptable`. LDP-NR’s cannot be added since indirect membership is not well defined for them, per _LDP 5.5.1.2_.
Constant Summary
Constants inherited from DirectContainer
DirectContainer::RELATION_TERMS
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
Instance Method Summary collapse
-
#container_class ⇒ RDF::URI
A URI representing the container type.
-
#create(input, content_type, &block) ⇒ Object
Creates and inserts default relation triples if none are given.
-
#inserted_content_relation ⇒ RDF::URI
Gives the inserted content relation for the indirect container.
Methods inherited from DirectContainer
#add, #make_membership_triple, #membership_constant_uri, #membership_predicate, #remove
Methods inherited from Container
#add, #add_containment_triple, #container?, #containment_triples, #has_containment_triple?, #make_containment_triple, #remove, #remove_containment_triple, #update
Methods inherited from RDFSource
#destroy, #graph, #initialize, #rdf_source?, #to_response, #update
Methods inherited from Resource
#allowed_methods, #container?, #containers, #destroy, #destroyed?, #etag, #exists?, find, gen_id, #initialize, interaction_model, #last_modified, #ldp_resource?, #match?, metagraph_name, #non_rdf_source?, #rdf_source?, #request, #to_response, #to_uri, #update
Constructor Details
This class inherits a constructor from RDF::LDP::RDFSource
Class Method Details
.to_uri ⇒ Object
21 22 23 |
# File 'lib/rdf/ldp/indirect_container.rb', line 21 def self.to_uri RDF::Vocab::LDP.IndirectContainer end |
Instance Method Details
#container_class ⇒ RDF::URI
Returns a URI representing the container type.
27 28 29 |
# File 'lib/rdf/ldp/indirect_container.rb', line 27 def container_class CONTAINER_CLASSES[:indirect] end |
#create(input, content_type, &block) ⇒ Object
Creates and inserts default relation triples if none are given.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rdf/ldp/indirect_container.rb', line 36 def create(input, content_type, &block) super graph.transaction(mutable: true) do |tx| tx.insert RDF::Statement(subject_uri, RDF::Vocab::LDP.insertedContentRelation, RDF::Vocab::LDP.MemberSubject) if inserted_content_statements.empty? end self end |
#inserted_content_relation ⇒ RDF::URI
Gives the inserted content relation for the indirect container. If none is present in the container state, we add ‘ldp:MemberSubject`, effectively treating this LDP-IC as an LDP-DC.
61 62 63 64 65 66 67 68 |
# File 'lib/rdf/ldp/indirect_container.rb', line 61 def inserted_content_relation statements = inserted_content_statements return statements.first.object if statements.count == 1 raise NotAcceptable.new('An LDP-IC MUST have exactly ' \ 'one inserted content relation triple; found ' \ "#{statements.count}.") end |