Class: Ductr::ETL::PaginatedSource
- Defined in:
- lib/ductr/etl/controls/paginated_source.rb
Overview
Base class to implement paginated source.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Control
#adapter, #job_method, #options
Instance Method Summary collapse
-
#each {|row| ... } ⇒ void
Iterates over pages and calls #each_page.
-
#each_page {|row| ... } ⇒ void
Called once per pages.
-
#page_size ⇒ Integer
The page size option, default to 10_000.
Methods inherited from Control
Constructor Details
This class inherits a constructor from Ductr::ETL::Control
Instance Method Details
#each {|row| ... } ⇒ void
This method returns an undefined value.
Iterates over pages and calls #each_page.
25 26 27 28 29 30 31 32 33 |
# File 'lib/ductr/etl/controls/paginated_source.rb', line 25 def each(&) @offset ||= 0 loop do break unless each_page(&) @offset += page_size end end |
#each_page {|row| ... } ⇒ void
This method returns an undefined value.
Called once per pages.
42 43 44 |
# File 'lib/ductr/etl/controls/paginated_source.rb', line 42 def each_page(&) raise NotImplementedError, "A paginated source must implement the `#each_page` method" end |
#page_size ⇒ Integer
The page size option, default to 10_000.
14 15 16 |
# File 'lib/ductr/etl/controls/paginated_source.rb', line 14 def page_size @options[:page_size] || 10_000 end |