Class: DynamodbRecord::HasManyThroughCollection
- Inherits:
-
Object
- Object
- DynamodbRecord::HasManyThroughCollection
- Includes:
- Enumerable
- Defined in:
- lib/dynamodb_record/has_many_through_collection.rb
Overview
Dynamodb::HasManyThroughCollection
is a class that represent a ManyToManyCollection
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(pager, base_object) ⇒ HasManyThroughCollection
constructor
A new instance of HasManyThroughCollection.
- #last_evaluated_key ⇒ Object
- #next_page ⇒ Object
- #next_page? ⇒ Boolean
- #page(last_key) ⇒ Object
Constructor Details
#initialize(pager, base_object) ⇒ HasManyThroughCollection
Returns a new instance of HasManyThroughCollection.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dynamodb_record/has_many_through_collection.rb', line 8 def initialize(pager, base_object) @base_object = base_object @pager = pager @klass = @pager.klass @options = @pager. @items = [] @pager.items.each do |item| # p item object = @klass.client.get_item( table_name: @klass.table_name, key: {id: item["#{@klass.to_s.downcase}_id"]} ) @items << @klass.send(:from_database, object.item) end end |
Instance Method Details
#each ⇒ Object
24 25 26 |
# File 'lib/dynamodb_record/has_many_through_collection.rb', line 24 def each(&) @items.each(&) end |
#last_evaluated_key ⇒ Object
28 29 30 |
# File 'lib/dynamodb_record/has_many_through_collection.rb', line 28 def last_evaluated_key @pager.last_evaluated_key end |
#next_page ⇒ Object
36 37 38 |
# File 'lib/dynamodb_record/has_many_through_collection.rb', line 36 def next_page self.class.new(@pager.next_page, @base_object) end |
#next_page? ⇒ Boolean
32 33 34 |
# File 'lib/dynamodb_record/has_many_through_collection.rb', line 32 def next_page? @pager ? @pager.next_page? : false end |
#page(last_key) ⇒ Object
40 41 42 |
# File 'lib/dynamodb_record/has_many_through_collection.rb', line 40 def page(last_key) self.class.new(@pager.next_page(last_key), @base_object) if last_key end |