Class: DynamodbRecord::ScanPager
- Defined in:
- lib/dynamodb_record/scan_pager.rb
Overview
Dynamodb::Page
is a class that include logic business from paginate
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#last_evaluated_key ⇒ Object
readonly
Returns the value of attribute last_evaluated_key.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from Pager
Instance Method Summary collapse
-
#initialize(options, klass) ⇒ ScanPager
constructor
A new instance of ScanPager.
- #next_page(last_key = nil) ⇒ Object
- #next_page? ⇒ Boolean
Constructor Details
#initialize(options, klass) ⇒ ScanPager
Returns a new instance of ScanPager.
8 9 10 11 12 13 |
# File 'lib/dynamodb_record/scan_pager.rb', line 8 def initialize(, klass) super(, klass) response = @klass.client.scan(@options) @items = response.items @last_evaluated_key = response.last_evaluated_key end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
6 7 8 |
# File 'lib/dynamodb_record/scan_pager.rb', line 6 def items @items end |
#last_evaluated_key ⇒ Object (readonly)
Returns the value of attribute last_evaluated_key.
6 7 8 |
# File 'lib/dynamodb_record/scan_pager.rb', line 6 def last_evaluated_key @last_evaluated_key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/dynamodb_record/scan_pager.rb', line 6 def @options end |
Instance Method Details
#next_page(last_key = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/dynamodb_record/scan_pager.rb', line 19 def next_page(last_key = nil) return nil unless next_page? @last_evaluated_key = last_key if last_key.present? @options.merge!(exclusive_start_key: last_evaluated_key) if next_page? self.class.new(@options, @klass) end |
#next_page? ⇒ Boolean
15 16 17 |
# File 'lib/dynamodb_record/scan_pager.rb', line 15 def next_page? last_evaluated_key ? true : false end |