Class: Valkyrie::Persistence::Fedora::ListNode
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Fedora::ListNode
- Defined in:
- lib/valkyrie/persistence/fedora/list_node.rb
Overview
Represents a node in an ORE List. Used for persisting ordered members into an RDF Graph for Fedora, to keep order maintained.
Defined Under Namespace
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#next ⇒ ActiveFedora::Orders::ListNode
Returns the next proxy or a tail sentinel.
-
#next_uri ⇒ Object
writeonly
Sets the attribute next_uri.
-
#prev ⇒ ActiveFedora::Orders::ListNode
Returns the previous proxy or a head sentinel.
-
#prev_uri ⇒ Object
writeonly
Sets the attribute prev_uri.
-
#proxy_for ⇒ Object
Returns the value of attribute proxy_for.
-
#proxy_in ⇒ Object
Returns the value of attribute proxy_in.
-
#rdf_subject ⇒ Object
readonly
Returns the value of attribute rdf_subject.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(node_cache, rdf_subject, adapter, graph = RDF::Repository.new) ⇒ ListNode
constructor
A new instance of ListNode.
- #target_id ⇒ Object
- #target_uri ⇒ Object
-
#to_graph ⇒ ActiveFedora::Orders::ListNode::Resource
Graph representation of node.
Constructor Details
#initialize(node_cache, rdf_subject, adapter, graph = RDF::Repository.new) ⇒ ListNode
Returns a new instance of ListNode.
12 13 14 15 16 17 18 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 12 def initialize(node_cache, rdf_subject, adapter, graph = RDF::Repository.new) @rdf_subject = rdf_subject @graph = graph @node_cache = node_cache @adapter = adapter Builder.new(rdf_subject, graph).populate(self) end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
11 12 13 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 11 def adapter @adapter end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
6 7 8 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 6 def graph @graph end |
#next ⇒ ActiveFedora::Orders::ListNode
Returns the next proxy or a tail sentinel.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 22 def next @next ||= if next_uri node_cache.fetch(next_uri) do node = self.class.new(node_cache, next_uri, adapter, graph) node.prev = self node end end end |
#next_uri=(value) ⇒ Object
Sets the attribute next_uri
9 10 11 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 9 def next_uri=(value) @next_uri = value end |
#prev ⇒ ActiveFedora::Orders::ListNode
Returns the previous proxy or a head sentinel.
35 36 37 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 35 def prev @prev ||= node_cache.fetch(prev_uri) if prev_uri end |
#prev_uri=(value) ⇒ Object
Sets the attribute prev_uri
9 10 11 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 9 def prev_uri=(value) @prev_uri = value end |
#proxy_for ⇒ Object
Returns the value of attribute proxy_for.
10 11 12 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 10 def proxy_for @proxy_for end |
#proxy_in ⇒ Object
Returns the value of attribute proxy_in.
10 11 12 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 10 def proxy_in @proxy_in end |
#rdf_subject ⇒ Object (readonly)
Returns the value of attribute rdf_subject.
6 7 8 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 6 def rdf_subject @rdf_subject end |
#target ⇒ Object
Returns the value of attribute target.
8 9 10 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 8 def target @target end |
Instance Method Details
#target_id ⇒ Object
55 56 57 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 55 def target_id adapter.uri_to_id(proxy_for) end |
#target_uri ⇒ Object
51 52 53 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 51 def target_uri adapter.id_to_uri(target_id.to_s) end |
#to_graph ⇒ ActiveFedora::Orders::ListNode::Resource
Graph representation of node.
41 42 43 44 45 46 47 48 49 |
# File 'lib/valkyrie/persistence/fedora/list_node.rb', line 41 def to_graph return RDF::Graph.new if target_id.blank? g = Resource.new(rdf_subject) g.proxy_for = target_uri g.proxy_in = proxy_in.try(:uri) g.next = self.next.try(:rdf_subject) g.prev = prev.try(:rdf_subject) g end |