Class: Moe::Sequence::ItemFetcher
- Inherits:
-
Object
- Object
- Moe::Sequence::ItemFetcher
- Defined in:
- lib/moe/sequence/item_fetcher.rb
Instance Attribute Summary collapse
-
#dyna ⇒ Object
Returns the value of attribute dyna.
-
#items ⇒ Object
Returns the value of attribute items.
-
#owner_id ⇒ Object
readonly
Returns the value of attribute owner_id.
-
#sequence_id ⇒ Object
Returns the value of attribute sequence_id.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
- #fetch(limit) ⇒ Object
-
#initialize(table_name, owner_id, uid) ⇒ ItemFetcher
constructor
A new instance of ItemFetcher.
Constructor Details
#initialize(table_name, owner_id, uid) ⇒ ItemFetcher
Returns a new instance of ItemFetcher.
7 8 9 10 11 12 13 14 |
# File 'lib/moe/sequence/item_fetcher.rb', line 7 def initialize(table_name, owner_id, uid) @dyna = Dyna.new @items = [] @owner_id = owner_id @sequence_id = 1 @table_name = table_name @uid = uid end |
Instance Attribute Details
#dyna ⇒ Object
Returns the value of attribute dyna.
4 5 6 |
# File 'lib/moe/sequence/item_fetcher.rb', line 4 def dyna @dyna end |
#items ⇒ Object
Returns the value of attribute items.
4 5 6 |
# File 'lib/moe/sequence/item_fetcher.rb', line 4 def items @items end |
#owner_id ⇒ Object (readonly)
Returns the value of attribute owner_id.
5 6 7 |
# File 'lib/moe/sequence/item_fetcher.rb', line 5 def owner_id @owner_id end |
#sequence_id ⇒ Object
Returns the value of attribute sequence_id.
4 5 6 |
# File 'lib/moe/sequence/item_fetcher.rb', line 4 def sequence_id @sequence_id end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
5 6 7 |
# File 'lib/moe/sequence/item_fetcher.rb', line 5 def table_name @table_name end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
5 6 7 |
# File 'lib/moe/sequence/item_fetcher.rb', line 5 def uid @uid end |
Instance Method Details
#fetch(limit) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/moe/sequence/item_fetcher.rb', line 16 def fetch(limit) request = { request_items: { table_name => { keys: [] } } } keys = request[:request_items][table_name][:keys] limit.times do keys << dyna.explode( Locksmith.key(owner_id, sequence_id, uid) ) self.sequence_id += 1 end munge dyna.dynamodb.batch_get_item(request) end |