Class: Valkyrie::Persistence::Fedora::OrderedReader
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Fedora::OrderedReader
- Includes:
- Enumerable
- Defined in:
- lib/valkyrie/persistence/fedora/ordered_reader.rb
Overview
Lazily iterates over a doubly linked list, fixing up nodes if necessary. Used for reading ordered members out of Fedora, and then converting them to member_ids.
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#each {|Valkyrie::Persistence::Fedora::OrderedList::HeadSentinel, Valkyrie::Persistence::Fedora::ListNode| ... } ⇒ Object
Enumerates through each node in the RDF linked list.
-
#initialize(root) ⇒ OrderedReader
constructor
A new instance of OrderedReader.
Constructor Details
#initialize(root) ⇒ OrderedReader
Returns a new instance of OrderedReader.
11 12 13 |
# File 'lib/valkyrie/persistence/fedora/ordered_reader.rb', line 11 def initialize(root) @root = root end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/valkyrie/persistence/fedora/ordered_reader.rb', line 8 def root @root end |
Instance Method Details
#each {|Valkyrie::Persistence::Fedora::OrderedList::HeadSentinel, Valkyrie::Persistence::Fedora::ListNode| ... } ⇒ Object
Enumerates through each node in the RDF linked list
17 18 19 20 21 22 23 24 25 |
# File 'lib/valkyrie/persistence/fedora/ordered_reader.rb', line 17 def each proxy = first_head while proxy yield proxy unless proxy.nil? next_proxy = proxy.next next_proxy.try(:prev=, proxy) if next_proxy&.prev != proxy proxy = next_proxy end end |