Sha256: 5aec10279762b314ab3300fa6b73b3c4237ccafdff30482660c78a9f8c531c2d

Contents?: true

Size: 957 Bytes

Versions: 8

Compression:

Stored size: 957 Bytes

Contents

require 'resync'
require_relative 'resource_client_delegate'

module Resync
  class Client
    module Mixins
      # A resource container whose resources are, themselves, resource containers
      module ListIndex
        prepend ResourceClientDelegate

        # Downloads and parses each resource list and returns a flattened enumeration
        # of all resources in each contained list. Each contained list is only downloaded
        # as needed, and only downloaded once.
        # @return [Enumerator::Lazy<Resync::Resource>] the flattened enumeration of resources
        def all_resources
          @resource_lists ||= {}
          resources.lazy.flat_map do |r|
            @resource_lists[r] ||= r.get_and_parse
            @resource_lists[r].resources
          end
        end
      end
    end
  end

  class ChangeListIndex
    prepend Client::Mixins::ListIndex
  end

  class ResourceListIndex
    prepend Client::Mixins::ListIndex
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
resync-client-0.4.3 lib/resync/client/mixins/list_index.rb
resync-client-0.4.2 lib/resync/client/mixins/list_index.rb
resync-client-0.4.1 lib/resync/client/mixins/list_index.rb
resync-client-0.4.0 lib/resync/client/mixins/list_index.rb
resync-client-0.3.5 lib/resync/client/mixins/list_index.rb
resync-client-0.3.4 lib/resync/client/mixins/list_index.rb
resync-client-0.3.3 lib/resync/client/mixins/list_index.rb
resync-client-0.3.2 lib/resync/client/mixins/list_index.rb