Sha256: 2a694c0673e8c97d6b9b64c4652c9f7ce3bc3bb29e9ff05a5d88d154a8fec4e7

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Awspec::Type
  class DynamodbTable < ResourceBase
    aws_resource Aws::DynamoDB::Table

    def resource_via_client
      @resource_via_client ||= find_dynamodb_table(@display_name)
    end

    def id
      @id ||= resource_via_client.table_name if resource_via_client
    end

    STATUSES = %w[
      CREATING
      UPDATING
      DELETING
      ACTIVE
    ]

    STATUSES.each do |status|
      define_method "#{status.downcase}?" do
        resource_via_client.table_status == status
      end
    end

    def has_attribute_definition?(name, type)
      ret = resource_via_client.attribute_definitions.select { |a| a.attribute_name == name }
      return false if ret.empty?
      return false unless ret.single_resource.attribute_type == type
      return true if ret.single_resource.attribute_name == name
    end

    def has_key_schema?(name, type)
      ret = resource_via_client.key_schema.select { |k| k.attribute_name == name }
      return false if ret.empty?
      return false unless ret.single_resource.key_type == type
      return true if ret.single_resource.attribute_name == name
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
awspec-1.31.0 lib/awspec/type/dynamodb_table.rb
awspec-1.30.0 lib/awspec/type/dynamodb_table.rb
awspec-1.29.3 lib/awspec/type/dynamodb_table.rb
awspec-1.29.2 lib/awspec/type/dynamodb_table.rb
awspec-1.29.1 lib/awspec/type/dynamodb_table.rb
awspec-1.29.0 lib/awspec/type/dynamodb_table.rb
awspec-1.28.2 lib/awspec/type/dynamodb_table.rb
awspec-1.28.1 lib/awspec/type/dynamodb_table.rb
awspec-1.28.0 lib/awspec/type/dynamodb_table.rb
awspec-1.27.1 lib/awspec/type/dynamodb_table.rb
awspec-1.27.0 lib/awspec/type/dynamodb_table.rb
awspec-1.26.0 lib/awspec/type/dynamodb_table.rb
awspec-1.25.2 lib/awspec/type/dynamodb_table.rb