Class: CloudFormation::DynamoDB::Table

Inherits:
Base
  • Object
show all
Defined in:
lib/cloud_formation/dynamo_db.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attribute_list, #build

Constructor Details

#initializeTable

Returns a new instance of Table.



24
25
26
# File 'lib/cloud_formation/dynamo_db.rb', line 24

def initialize
  @attribute_definitions = []
end

Instance Attribute Details

#attribute_definitionsObject

Returns the value of attribute attribute_definitions.



22
23
24
# File 'lib/cloud_formation/dynamo_db.rb', line 22

def attribute_definitions
  @attribute_definitions
end

Instance Method Details

#add_attribute(attr_name, attr_value) ⇒ Object



43
44
45
# File 'lib/cloud_formation/dynamo_db.rb', line 43

def add_attribute attr_name, attr_value
  @attribute_definitions << { "AttributeName" => attr_name.to_s, "AttributeType" => type_mapping(attr_value) }
end

#serializeObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cloud_formation/dynamo_db.rb', line 28

def serialize
  properties = {
    "Type" => "AWS::DynamoDB::Table",
    "Properties" => {
      "ProvisionedThroughput" => {
        "WriteCapacityUnits" => @write_capacity_units.to_s,
        "ReadCapacityUnits" => @read_capacity_units.to_s
      }
    }
  }
  properties["Properties"].merge! add_key_schemas
  properties["Properties"]["AttributeDefinitions"] = @attribute_definitions unless @attribute_definitions.empty?
  properties
end