Skip to content

Commit

Permalink
Refactoring. Minor changes in Criteria::Chain module
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed Aug 17, 2019
1 parent 8de57b7 commit 347f6bf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/dynamoid/criteria/chain.rb
Expand Up @@ -195,9 +195,12 @@ def pages
#
# @since 3.1.0
def pages_via_query
Enumerator.new do |yielder|
Enumerator.new do |y|
Dynamoid.adapter.query(source.table_name, range_query).each do |items, metadata|
yielder.yield items.map { |hash| source.from_database(hash) }, metadata.slice(:last_evaluated_key)
page = items.map { |h| source.from_database(h) }
options = metadata.slice(:last_evaluated_key)

y.yield page, options
end
end
end
Expand All @@ -208,9 +211,12 @@ def pages_via_query
#
# @since 3.1.0
def pages_via_scan
Enumerator.new do |yielder|
Enumerator.new do |y|
Dynamoid.adapter.scan(source.table_name, scan_query, scan_opts).each do |items, metadata|
yielder.yield(items.map { |hash| source.from_database(hash) }, metadata.slice(:last_evaluated_key))
page = items.map { |h| source.from_database(h) }
options = metadata.slice(:last_evaluated_key)

y.yield page, options
end
end
end
Expand Down

0 comments on commit 347f6bf

Please sign in to comment.