Class: ActiveFedora::Aggregation::OrderedReader
- Inherits:
-
Object
- Object
- ActiveFedora::Aggregation::OrderedReader
- Includes:
- Enumerable
- Defined in:
- lib/active_fedora/aggregation/ordered_reader.rb
Overview
Lazily iterates over a doubly linked list, fixing up nodes if necessary.
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(root) ⇒ OrderedReader
constructor
A new instance of OrderedReader.
Constructor Details
#initialize(root) ⇒ OrderedReader
Returns a new instance of OrderedReader.
7 8 9 |
# File 'lib/active_fedora/aggregation/ordered_reader.rb', line 7 def initialize(root) @root = root end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/active_fedora/aggregation/ordered_reader.rb', line 6 def root @root end |
Instance Method Details
#each ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/active_fedora/aggregation/ordered_reader.rb', line 11 def each proxy = first_head while proxy yield proxy unless proxy.nil? next_proxy = proxy.next next_proxy.try(:prev=, proxy) if next_proxy && next_proxy.prev != proxy proxy = next_proxy end end |