class Dynamocli::Table::StandaloneTable

Constants

DYNAMODB
LOGGER

Attributes

dynamodb[R]
logger[R]
table[R]
table_name[R]

Public Class Methods

new(table_name:, table:, dynamodb: nil, logger: nil) click to toggle source
# File lib/dynamocli/table/standalone_table.rb, line 8
def initialize(table_name:, table:, dynamodb: nil, logger: nil)
  @table_name = table_name
  @table = table
  @dynamodb = dynamodb || DYNAMODB.new
  @logger = logger || LOGGER.new
end

Public Instance Methods

alert_message_before_continue() click to toggle source
# File lib/dynamocli/table/standalone_table.rb, line 15
def alert_message_before_continue
  "You're going to drop and recreate your #{@table_name} table!"
end
erase() click to toggle source
# File lib/dynamocli/table/standalone_table.rb, line 19
def erase
  delete_table
  wait_for_deletion_to_complete
  create_table
end

Private Instance Methods

create_table() click to toggle source
# File lib/dynamocli/table/standalone_table.rb, line 49
def create_table
  logger.info("Creating the #{table_name} table")

  dynamodb.create_table(table.schema)

  logger.success("#{table_name} table created")
end
delete_table() click to toggle source
# File lib/dynamocli/table/standalone_table.rb, line 33
def delete_table
  logger.info("Deleting the #{table_name} table")

  table.delete

  logger.success("#{table_name} table deleted")
end
wait_for_deletion_to_complete() click to toggle source
# File lib/dynamocli/table/standalone_table.rb, line 41
def wait_for_deletion_to_complete
  waiting_seconds = 0
  while table.deleting?
    logger.info("Waiting for deletion to complete")
    sleep waiting_seconds += 1
  end
end