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 collapse
- INSERTED_CONTENT_REL_URI =
RDF::Vocab::LDP.insertedContentRelation.freeze
- MEMBER_SUBJECT_URI =
RDF::Vocab::LDP.MemberSubject.freeze
Constants inherited from DirectContainer
DirectContainer::MEMBERSHIP_RESOURCE_URI, DirectContainer::MEMBER_URI, DirectContainer::RELATION_TERMS
Constants inherited from Resource
Resource::CONTAINS_URI, Resource::INVALIDATED_AT_URI, Resource::MODIFIED_URI
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) ⇒ 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
24 25 26 |
# File 'lib/rdf/ldp/indirect_container.rb', line 24 def self.to_uri RDF::Vocab::LDP.IndirectContainer end |
Instance Method Details
#container_class ⇒ RDF::URI
Returns a URI representing the container type.
30 31 32 |
# File 'lib/rdf/ldp/indirect_container.rb', line 30 def container_class CONTAINER_CLASSES[:indirect] end |
#create(input, content_type) ⇒ Object
Creates and inserts default relation triples if none are given.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rdf/ldp/indirect_container.rb', line 39 def create(input, content_type) super graph.transaction(mutable: true) do |tx| if inserted_content_statements.empty? tx.insert RDF::Statement(subject_uri, INSERTED_CONTENT_REL_URI, MEMBER_SUBJECT_URI) end 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.
65 66 67 68 69 70 71 72 |
# File 'lib/rdf/ldp/indirect_container.rb', line 65 def inserted_content_relation statements = inserted_content_statements return statements.first.object if statements.count == 1 raise(NotAcceptable, 'An LDP-IC MUST have exactly ' \ 'one inserted content relation triple; found ' \ "#{statements.count}.") end |