Class: ActiveFedora::Orders::ListNode
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveFedora::Orders::ListNode
 
 
- Defined in:
 - lib/active_fedora/orders/list_node.rb
 
Defined Under Namespace
Classes: Builder, MaybeID, Resource
Instance Attribute Summary collapse
- 
  
    
      #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  ⇒ ActiveFedora::Base 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Object representation of proxyFor.
 
Instance Method Summary collapse
- #changed_for_autosave? ⇒ Boolean
 - 
  
    
      #destroyed?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Methods necessary for association functionality.
 - 
  
    
      #initialize(node_cache, rdf_subject, graph = RDF::Repository.new)  ⇒ ListNode 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of ListNode.
 - #marked_for_destruction? ⇒ Boolean
 - #new_record? ⇒ Boolean
 - #proxy_in_id ⇒ Object
 - 
  
    
      #save_target  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Persists target if it’s been accessed or set.
 - #target_id ⇒ Object
 - #target_uri ⇒ Object
 - 
  
    
      #to_graph  ⇒ ActiveFedora::Orders::ListNode::Resource 
    
    
  
  
  
  
  
  
  
  
  
    
Graph representation of node.
 - #valid? ⇒ Boolean
 
Constructor Details
#initialize(node_cache, rdf_subject, graph = RDF::Repository.new) ⇒ ListNode
Returns a new instance of ListNode.
      6 7 8 9 10 11  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 6 def initialize(node_cache, rdf_subject, graph = RDF::Repository.new) @rdf_subject = rdf_subject @graph = graph @node_cache = node_cache Builder.new(rdf_subject, graph).populate(self) end  | 
  
Instance Attribute Details
#next ⇒ ActiveFedora::Orders::ListNode
Returns the next proxy or a tail sentinel.
      15 16 17 18 19 20 21 22 23 24  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 15 def next @next ||= if next_uri node_cache.fetch(next_uri) do node = self.class.new(node_cache, next_uri, graph) node.prev = self node end end end  | 
  
#next_uri=(value) ⇒ Object
Sets the attribute next_uri
      4 5 6  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 4 def next_uri=(value) @next_uri = value end  | 
  
#prev ⇒ ActiveFedora::Orders::ListNode
Returns the previous proxy or a head sentinel.
      28 29 30 31 32 33 34 35 36 37  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 28 def prev @prev ||= if prev_uri node_cache.fetch(prev_uri) do node = self.class.new(node_cache, prev_uri, graph) node.next = self node end end end  | 
  
#prev_uri=(value) ⇒ Object
Sets the attribute prev_uri
      4 5 6  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 4 def prev_uri=(value) @prev_uri = value end  | 
  
#proxy_for ⇒ Object
Returns the value of attribute proxy_for.
      5 6 7  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 5 def proxy_for @proxy_for end  | 
  
#proxy_in ⇒ Object
Returns the value of attribute proxy_in.
      5 6 7  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 5 def proxy_in @proxy_in end  | 
  
#rdf_subject ⇒ Object (readonly)
Returns the value of attribute rdf_subject.
      3 4 5  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 3 def rdf_subject @rdf_subject end  | 
  
#target ⇒ ActiveFedora::Base
Object representation of proxyFor
      52 53 54 55 56 57 58 59  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 52 def target @target ||= if proxy_for.present? node_cache.fetch(proxy_for) do ActiveFedora::Base.from_uri(proxy_for, nil) end end end  | 
  
Instance Method Details
#changed_for_autosave? ⇒ Boolean
      117 118 119  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 117 def changed_for_autosave? true end  | 
  
#destroyed? ⇒ Boolean
Methods necessary for association functionality
      105 106 107  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 105 def destroyed? false end  | 
  
#marked_for_destruction? ⇒ Boolean
      109 110 111  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 109 def marked_for_destruction? false end  | 
  
#new_record? ⇒ Boolean
      121 122 123  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 121 def new_record? @target&.new_record? end  | 
  
#proxy_in_id ⇒ Object
      78 79 80  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 78 def proxy_in_id MaybeID.new(@proxy_in.try(:id) || proxy_in).value end  | 
  
#save_target ⇒ Object
Persists target if it’s been accessed or set.
      70 71 72 73 74 75 76  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 70 def save_target if @target @target.save else true end end  | 
  
#target_id ⇒ Object
      65 66 67  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 65 def target_id MaybeID.new(@target.try(:id) || proxy_for).value end  | 
  
#target_uri ⇒ Object
      61 62 63  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 61 def target_uri RDF::URI(ActiveFedora::Base.id_to_uri(target_id)) if target_id end  | 
  
#to_graph ⇒ ActiveFedora::Orders::ListNode::Resource
Graph representation of node.
      41 42 43 44 45 46 47 48  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 41 def to_graph 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  | 
  
#valid? ⇒ Boolean
      113 114 115  | 
    
      # File 'lib/active_fedora/orders/list_node.rb', line 113 def valid? true end  |