Sha256: 757d645715c55bc946091c5956896ed60ad60b2a50401491b06e762b4df68022

Contents?: true

Size: 969 Bytes

Versions: 4

Compression:

Stored size: 969 Bytes

Contents

require 'resync'
require 'resync/client/mixins/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

4 entries across 4 versions & 1 rubygems

Version Path
resync-client-0.4.7 lib/resync/client/mixins/list_index.rb
resync-client-0.4.6 lib/resync/client/mixins/list_index.rb
resync-client-0.4.5 lib/resync/client/mixins/list_index.rb
resync-client-0.4.4 lib/resync/client/mixins/list_index.rb