Class: DynamodbRecord::Collection
- Inherits:
-
Object
- Object
- DynamodbRecord::Collection
- Includes:
- Enumerable
- Defined in:
- lib/dynamodb_record/collection.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(pager, base_object) ⇒ Collection
constructor
attr_reader :last_evaluated_key.
- #last_evaluated_key ⇒ Object
- #next_page ⇒ Object
- #next_page? ⇒ Boolean
- #page(last_key) ⇒ Object
Constructor Details
#initialize(pager, base_object) ⇒ Collection
attr_reader :last_evaluated_key
9 10 11 12 13 14 15 16 |
# File 'lib/dynamodb_record/collection.rb', line 9 def initialize(pager, base_object) @base_object = base_object @pager = pager @klass = @pager.klass @options = @pager. items = @pager.items @items = items.map { |item| @klass.send(:from_database, item) } end |
Instance Method Details
#each ⇒ Object
18 19 20 |
# File 'lib/dynamodb_record/collection.rb', line 18 def each(&) @items.each(&) end |
#last_evaluated_key ⇒ Object
22 23 24 |
# File 'lib/dynamodb_record/collection.rb', line 22 def last_evaluated_key @pager.last_evaluated_key end |
#next_page ⇒ Object
30 31 32 |
# File 'lib/dynamodb_record/collection.rb', line 30 def next_page self.class.new(@pager.next_page, @base_object) end |
#next_page? ⇒ Boolean
26 27 28 |
# File 'lib/dynamodb_record/collection.rb', line 26 def next_page? @pager ? @pager.next_page? : false end |
#page(last_key) ⇒ Object
34 35 36 |
# File 'lib/dynamodb_record/collection.rb', line 34 def page(last_key) self.class.new(@pager.next_page(last_key), @base_object) if last_key end |