Class: Shoryuken::Later::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/shoryuken/later/client.rb

Constant Summary collapse

@@tables =
{}

Class Method Summary collapse

Class Method Details

.ddbObject



20
21
22
# File 'lib/shoryuken/later/client.rb', line 20

def ddb
  @ddb ||= AWS::DynamoDB.new
end

.put_item(table, attributes, options = {unless_exists: 'id'}) ⇒ Object



15
16
17
18
# File 'lib/shoryuken/later/client.rb', line 15

def put_item(table, attributes, options={unless_exists: 'id'})
  attributes['id'] ||= SecureRandom.uuid
  tables(table).items.create(attributes, options)
end

.tables(table) ⇒ Object



9
10
11
12
13
# File 'lib/shoryuken/later/client.rb', line 9

def tables(table)
  @@tables[table.to_s] ||= ddb.tables[table].tap do |tbl|
    tbl.hash_key = [:id, :string]
  end
end