Class: Rom::Dynamo::Relation

Inherits:
ROM::Relation
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rom/dynamo/relation.rb

Instance Method Summary collapse

Instance Method Details

#each_page(&block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/rom/dynamo/relation.rb', line 9

def each_page(&block)
  return enum_for(:each_page) if block.nil?
  dataset.each_page do |page|
    items = page[:items].map { |t| output_schema[t] }
    items = mapper.(items).to_a if auto_map?
    hash = page.to_hash.merge(items: items)
    hash[:last_evaluated_key] ||= nil
    block.call(ROM::OpenStruct.new(hash))
  end
end