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::Repository.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::Repository.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:



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)


118
119
120
# File 'lib/active_fedora/orders/list_node.rb', line 118

def changed_for_autosave?
  true
end

#destroyed?Boolean

Methods necessary for association functionality

Returns:

  • (Boolean)


106
107
108
# File 'lib/active_fedora/orders/list_node.rb', line 106

def destroyed?
  false
end

#marked_for_destruction?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/active_fedora/orders/list_node.rb', line 110

def marked_for_destruction?
  false
end

#new_record?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/active_fedora/orders/list_node.rb', line 122

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

#proxy_in_idObject



79
80
81
# File 'lib/active_fedora/orders/list_node.rb', line 79

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.



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

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

#target_idObject



66
67
68
# File 'lib/active_fedora/orders/list_node.rb', line 66

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

#target_uriObject



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

def target_uri
  RDF::URI(ActiveFedora::Base.id_to_uri(target_id)) if target_id
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 = prev.try(:rdf_subject)
  g
end

#valid?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/active_fedora/orders/list_node.rb', line 114

def valid?
  true
end