Sha256: 41a199c1787e30a5d0e4d1b5dc6ddb3a7d67869abf78cb89ff2eaedcff6505ee

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'dm-chunked_query/chunks'

module DataMapper
  module ChunkedQuery
    module Mixin
      #
      # Allows chunked access to the resources from a query.
      #
      # @param [Integer] per_chunk
      #   The number of resources per-chunk.
      #
      # @return [Chunks]
      #   The abstract collection of chunks from the query.
      #
      def chunks(per_chunk)
        Chunks.new(self,per_chunk)
      end

      #
      # @see #chunks
      #
      def chunks_of(per_chunk)
        chunks(per_chunk)
      end

      #
      # Enumerate over every chunk.
      #
      # @param [Integer] per_chunk
      #   The number of resources per-chunk.
      #
      # @yield [chunk]
      #   A chunk of resources within the query.
      #
      # @yieldparam [DataMapper::Collection] chunk
      #   A collection of resources that makes up the chunk.
      #
      # @return [Chunks]
      #   The abstract collection of chunks from the query.
      #
      # @see #chunks
      #
      # @since 0.2.0
      #
      def each_chunk(per_chunk,&block)
        chunks(per_chunk).each(&block)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-chunked_query-0.2.1 lib/dm-chunked_query/mixin.rb