class Shoryuken::Later::Client

Public Class Methods

create_item(table, item) click to toggle source
# File lib/shoryuken/later/client.rb, line 22
def create_item(table, item)
  item['id'] ||= SecureRandom.uuid
  
  ddb.put_item(table_name: table, item: item,
               expected: {id: {exists: false}})
end
ddb() click to toggle source
# File lib/shoryuken/later/client.rb, line 34
def ddb
  @ddb ||= Aws::DynamoDB::Client.new
end
delete_item(table, item) click to toggle source
# File lib/shoryuken/later/client.rb, line 29
def delete_item(table, item)
  ddb.delete_item(table_name: table, key: {id: item['id']},
                  expected: {id: {value: item['id'], exists: true}})
end
first_item(table, filter=nil) click to toggle source
# File lib/shoryuken/later/client.rb, line 13
def first_item(table, filter=nil)
  item = nil
  response = ddb.scan(table_name: table, limit: 1, scan_filter: filter)
  response.each do |result|
    item = result.items.first and break
  end
  item
end
tables(table) click to toggle source
# File lib/shoryuken/later/client.rb, line 9
def tables(table)
  @@tables[table] ||= ddb.describe_table(table_name: table)
end