Class: Metacrunch::DB::Source
- Inherits:
-
Object
- Object
- Metacrunch::DB::Source
- Defined in:
- lib/metacrunch/db/source.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ rows_per_fetch: 1000, strategy: :filter, filter_values: nil }
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(sequel_dataset, options = {}) ⇒ Source
constructor
A new instance of Source.
Constructor Details
#initialize(sequel_dataset, options = {}) ⇒ Source
Returns a new instance of Source.
12 13 14 15 16 17 18 19 |
# File 'lib/metacrunch/db/source.rb', line 12 def initialize(sequel_dataset, = {}) @dataset = sequel_dataset @options = DEFAULT_OPTIONS.merge() unless @dataset.opts[:order] raise ArgumentError, "The dataset must be ordered." end end |
Instance Method Details
#each(&block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/metacrunch/db/source.rb', line 21 def each(&block) return enum_for(__method__) unless block_given? @dataset.paged_each( rows_per_fetch: @options[:rows_per_fetch], strategy: @options[:strategy], filter_values: @options[:filter_values] ) do |row| yield(row) end self end |