class Moe::Sequence::Collection
Attributes
dyna[RW]
owner_id[R]
read_tables[R]
Public Class Methods
new(name, owner_id)
click to toggle source
# File lib/moe/sequence/collection.rb, line 7 def initialize(name, owner_id) @dyna = Dyna.new @owner_id = owner_id @read_tables = Moe.config.tables[name].first end
Public Instance Methods
metadata_items()
click to toggle source
# File lib/moe/sequence/collection.rb, line 13 def metadata_items [].tap do |results| read_tables.each do |table_name| dyna.dynamodb.query(request table_name).items.each do |item| results << process(table_name, item) end end end end
Private Instance Methods
process(table_name, item)
click to toggle source
# File lib/moe/sequence/collection.rb, line 27 def process(table_name, item) MetadataItem.new( table_name, owner_id, item["range"].s.gsub(/0\./, ""), item["count"].s.to_i, MultiJson.load(item["payload"].s) ) end
request(table_name)
click to toggle source
# File lib/moe/sequence/collection.rb, line 35 def request(table_name) { table_name: table_name, key_conditions: { hash: { attribute_value_list: [ { s: owner_id } ], comparison_operator: "EQ" }, range: { attribute_value_list: [ { s: "0" } ], comparison_operator: "BEGINS_WITH" } } } end