Class: ActiveFedora::Orders::ListNode

Inherits:
Object
  • Object
show all
Defined in:
lib/active_fedora/orders/list_node.rb

Defined Under Namespace

Classes: Builder, MaybeID, Resource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_cache, rdf_subject, graph = RDF::Graph.new) ⇒ ListNode

Returns a new instance of ListNode.



7
8
9
10
11
12
# File 'lib/active_fedora/orders/list_node.rb', line 7

def initialize(node_cache, rdf_subject, graph=RDF::Graph.new)
  @rdf_subject = rdf_subject
  @graph = graph
  @node_cache = node_cache
  Builder.new(rdf_subject, graph).populate(self)
end

Instance Attribute Details

#nextActiveFedora::Orders::ListNode

Returns the next proxy or a tail sentinel.



16
17
18
# File 'lib/active_fedora/orders/list_node.rb', line 16

def next
  @next
end

#next_uri=(value) ⇒ Object

Sets the attribute next_uri

Parameters:

  • value

    the value to set the attribute next_uri to.



5
6
7
# File 'lib/active_fedora/orders/list_node.rb', line 5

def next_uri=(value)
  @next_uri = value
end

#prevActiveFedora::Orders::ListNode

Returns the previous proxy or a head sentinel.



29
30
31
# File 'lib/active_fedora/orders/list_node.rb', line 29

def prev
  @prev
end

#prev_uri=(value) ⇒ Object

Sets the attribute prev_uri

Parameters:

  • value

    the value to set the attribute prev_uri to.



5
6
7
# File 'lib/active_fedora/orders/list_node.rb', line 5

def prev_uri=(value)
  @prev_uri = value
end

#proxy_forObject

Returns the value of attribute proxy_for.



6
7
8
# File 'lib/active_fedora/orders/list_node.rb', line 6

def proxy_for
  @proxy_for
end

#proxy_inObject

Returns the value of attribute proxy_in.



6
7
8
# File 'lib/active_fedora/orders/list_node.rb', line 6

def proxy_in
  @proxy_in
end

#rdf_subjectObject (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

#targetActiveFedora::Base

Object representation of proxyFor

Returns:

  • (ActiveFedora::Base)


53
54
55
# File 'lib/active_fedora/orders/list_node.rb', line 53

def target
  @target
end

Instance Method Details

#changed_for_autosave?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/active_fedora/orders/list_node.rb', line 120

def changed_for_autosave?
  true
end

#destroyed?Boolean

Methods necessary for association functionality

Returns:

  • (Boolean)


108
109
110
# File 'lib/active_fedora/orders/list_node.rb', line 108

def destroyed?
  false
end

#marked_for_destruction?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/active_fedora/orders/list_node.rb', line 112

def marked_for_destruction?
  false
end

#new_record?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/active_fedora/orders/list_node.rb', line 124

def new_record?
  @target && @target.new_record?
end

#proxy_in_idObject



81
82
83
# File 'lib/active_fedora/orders/list_node.rb', line 81

def proxy_in_id
  MaybeID.new(@proxy_in.try(:id) || proxy_in).value
end

#save_targetObject

Persists target if it’s been accessed or set.



73
74
75
76
77
78
79
# File 'lib/active_fedora/orders/list_node.rb', line 73

def save_target
  if @target
    @target.save
  else
    true
  end
end

#target_idObject



68
69
70
# File 'lib/active_fedora/orders/list_node.rb', line 68

def target_id
  MaybeID.new(@target.try(:id) || proxy_for).value
end

#target_uriObject



62
63
64
65
66
# File 'lib/active_fedora/orders/list_node.rb', line 62

def target_uri
  if target_id
    RDF::URI(ActiveFedora::Base.id_to_uri(target_id))
  end
end

#to_graphActiveFedora::Orders::ListNode::Resource

Graph representation of node.



42
43
44
45
46
47
48
49
# File 'lib/active_fedora/orders/list_node.rb', line 42

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 = self.prev.try(:rdf_subject)
  g
end

#valid?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/active_fedora/orders/list_node.rb', line 116

def valid?
  true
end