Class: Ductr::SequelBase::PaginatedSource

Inherits:
ETL::PaginatedSource show all
Defined in:
lib/ductr/sequel_base/paginated_source.rb

Overview

A source control that allows to select a big number of rows by relying on pagination.

Instance Attribute Summary

Attributes inherited from ETL::Control

#adapter, #job_method, #options

Instance Method Summary collapse

Methods inherited from ETL::PaginatedSource

#each, #page_size

Methods inherited from ETL::Source

#each

Methods inherited from ETL::Control

#call_method, #initialize

Constructor Details

This class inherits a constructor from Ductr::ETL::Control

Instance Method Details

#each_page { ... } ⇒ Boolean

Calls the job’s method and iterate on the query result. Returns true if the page is full, false otherwise.

Yields:

  • The each block

Returns:

  • (Boolean)

    True if the page is full, false otherwise.

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ductr/sequel_base/paginated_source.rb', line 18

def each_page(&)
  rows_count = 0

  call_method(adapter.db, @offset, page_size).each do |row|
    yield(row)
    rows_count += 1
  end

  if rows_count > page_size
    raise InconsistentPaginationError,
          "The query returned #{rows_count} rows but the page size is #{page_size} rows"
  end

  rows_count == page_size
end