Sha256: 164d705a8ecb5fefd4ecc695f2ceb3d8b5c408d36174815f6e533fa878e40348

Contents?: true

Size: 559 Bytes

Versions: 69

Compression:

Stored size: 559 Bytes

Contents

module ActiveFedora::Aggregation
  ##
  # Lazily iterates over a doubly linked list, fixing up nodes if necessary.
  class OrderedReader
    include Enumerable
    attr_reader :root
    def initialize(root)
      @root = root
    end

    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

    private

      def first_head
        root.head
      end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
active-fedora-15.0.1 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-15.0.0 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-14.0.1 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-14.0.0 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-13.3.0 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-12.2.4 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-13.2.7 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-13.2.5 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-13.2.4 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-12.2.3 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-13.2.3 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-13.2.2 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-13.2.0 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-13.1.3 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-11.5.6 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-12.2.2 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-11.2.1 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-12.2.1 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-12.0.3 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-11.5.5 lib/active_fedora/aggregation/ordered_reader.rb