Class: CfFactory::CfDynamoTable

Inherits:
Object
  • Object
show all
Includes:
CfBase
Defined in:
lib/cf_factory/dynamo/cf_dynamo_table.rb

Instance Method Summary collapse

Methods included from CfBase

#generate, #generate_ref, #get_deletion_policy, #get_name, #get_update_policy, #hash_to_string, #retrieve_attribute, #set_meta_data, #set_quotes, #set_tags

Constructor Details

#initialize(name, read_capacity_units, write_capacity_units, hash_key_name, hash_key_type, range_key_name = nil, range_key_type = nil) ⇒ CfDynamoTable

Returns a new instance of CfDynamoTable.



6
7
8
9
10
11
12
13
14
# File 'lib/cf_factory/dynamo/cf_dynamo_table.rb', line 6

def initialize(name, read_capacity_units, write_capacity_units, hash_key_name, hash_key_type, range_key_name = nil, range_key_type = nil)
  @name = name
  @hash_key_name = hash_key_name
  @hash_key_type = hash_key_type
  @range_key_name = range_key_name
  @range_key_type = range_key_type
  @read_capacity_units = read_capacity_units
  @write_capacity_units = write_capacity_units
end

Instance Method Details

#get_cf_attributesObject



24
25
26
# File 'lib/cf_factory/dynamo/cf_dynamo_table.rb', line 24

def get_cf_attributes
  result = super
end

#get_cf_propertiesObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cf_factory/dynamo/cf_dynamo_table.rb', line 28

def get_cf_properties
  result = {} 
  if @range_key_name then
    result["KeySchema"] = { 
      "HashKeyElement" => { "AttributeName" => @hash_key_name, "AttributeType" => @hash_key_type },
      "RangeKeyElement" => { "AttributeName" => @range_key_name, "AttributeType" => @range_key_type}
    }
  else
    result["KeySchema"] = {
      "HashKeyElement" => { "AttributeName" => @hash_key_name, "AttributeType" => @hash_key_type }
    }
  end
  result["ProvisionedThroughput"] = { "ReadCapacityUnits" => @read_capacity_units, "WriteCapacityUnits" => @write_capacity_units }
  result
end

#get_cf_typeObject



20
21
22
# File 'lib/cf_factory/dynamo/cf_dynamo_table.rb', line 20

def get_cf_type
  "AWS::DynamoDB::Table"
end

#set_deletion_policy(deletion_policy) ⇒ Object



16
17
18
# File 'lib/cf_factory/dynamo/cf_dynamo_table.rb', line 16

def set_deletion_policy(deletion_policy)
  @deletion_policy = deletion_policy
end