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-10.1.0.rc1 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-10.0.0 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-10.0.0.beta4 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-10.0.0.beta3 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-10.0.0.beta2 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-10.0.0.beta1 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-9.13.0 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-9.12.0 lib/active_fedora/aggregation/ordered_reader.rb
active-fedora-9.11.0 lib/active_fedora/aggregation/ordered_reader.rb