Class DataMapper::ChunkedQuery::Chunks
In: lib/dm-chunked_query/chunks.rb
Parent: Object

Represents the abstract collection of Chunks.

Methods

[]   at   chunk_at   count   each   first   length   new   size  

Included Modules

Enumerable

Attributes

per_chunk  [R]  The number of resources per chunk

Public Class methods

Creates a new collection of Chunks.

@param [DataMapper::Model, DataMapper::Collection] query

  The model or collection to access via chunks.

@param [Integer] per_chunk

  The number of records per-chunk.

Public Instance methods

Provides random access to chunks.

@param [Range<Integer>, Integer] key

  The index or range of indices to access.

@return [DataMapper::Collection]

  A collection of resources at the given index or indices.

Accesses a chunk at a specific index.

@param [to_i] index

  The index to access.

@return [DataMapper::Collection]

  The chunk of resources at the given index.

Counts how many underlying resources are available.

@return [Integer]

  The total number of resources.

Enumerates over each chunk in the collection of Chunks.

@yield [chunk]

  The given block will be passed each chunk.

@yieldparam [DataMapper::Collection] chunk

  The collection of resources that makes up a chunk.

@return [Enumerator]

  If no block is given, an Enumerator object will be returned.

Returns the first chunk(s).

@param [Integer] n

  The number of sub-chunks to include.

@return [DataMapper::Collection]

  The first chunk of resources.

@raise [ArgumentError]

  The number of sub-chunks was negative.

@since 0.2.0

Calculate the number of Chunks.

@return [Integer]

  The number of available Chunks.
size()

Alias for length

Protected Instance methods

Creates a chunk of resources.

@param [Integer] index

  The index of the chunk.

@param [Integer] span

  The number of chunks the chunk should span.

@return [DataMapper::Collection]

  The collection of resources that makes up the chunk.

[Validate]