Sha256: 89fec1184306b4949f93aab28bda403695a8a7fbcacfdfa95dd492819d143673

Contents?: true

Size: 1.1 KB

Versions: 116

Compression:

Stored size: 1.1 KB

Contents

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

116 entries across 116 versions & 4 rubygems

Version Path
awspec-1.25.1 lib/awspec/type/dynamodb_table.rb
awspec-1.25.0 lib/awspec/type/dynamodb_table.rb
awspec-1.24.4 lib/awspec/type/dynamodb_table.rb
awspec-1.24.3 lib/awspec/type/dynamodb_table.rb
awspec-1.24.2 lib/awspec/type/dynamodb_table.rb
awspec-1.24.1 lib/awspec/type/dynamodb_table.rb
awspec-1.24.0 lib/awspec/type/dynamodb_table.rb
awspec-1.23.0 lib/awspec/type/dynamodb_table.rb
awspec-1.22.1 lib/awspec/type/dynamodb_table.rb
awspec-1.22.0 lib/awspec/type/dynamodb_table.rb
awspec-1.21.1 lib/awspec/type/dynamodb_table.rb
awspec-1.21.0 lib/awspec/type/dynamodb_table.rb
awspec-1.20.0 lib/awspec/type/dynamodb_table.rb
awspec-1.19.2 lib/awspec/type/dynamodb_table.rb
awspec-1.19.1 lib/awspec/type/dynamodb_table.rb
awspec-1.19.0 lib/awspec/type/dynamodb_table.rb
cthiesfork-awspec-1.2.4 lib/awspec/type/dynamodb_table.rb
awspec-api_gateway_extended-1.2.4 lib/awspec/type/dynamodb_table.rb
awspec-api_gateway_extended-1.2.3 lib/awspec/type/dynamodb_table.rb
awspec-1.18.6 lib/awspec/type/dynamodb_table.rb