Class: Xaases::Aws::Dynamodb
- Inherits:
-
Object
- Object
- Xaases::Aws::Dynamodb
- Defined in:
- lib/xaases/aws/dynamodb.rb
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #attribute_definitions ⇒ Object
-
#initialize(name, *keys) ⇒ Dynamodb
constructor
A new instance of Dynamodb.
- #key_schema ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name, *keys) ⇒ Dynamodb
Returns a new instance of Dynamodb.
5 6 7 8 |
# File 'lib/xaases/aws/dynamodb.rb', line 5 def initialize(name, *keys) @name = name @keys = keys end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
4 5 6 |
# File 'lib/xaases/aws/dynamodb.rb', line 4 def keys @keys end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/xaases/aws/dynamodb.rb', line 4 def name @name end |
Instance Method Details
#attribute_definitions ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/xaases/aws/dynamodb.rb', line 10 def attribute_definitions keys.map do |key, type| { "AttributeName" => key, "AttributeType" => (type == 'integer' ? 'N' : 'S') } end end |
#key_schema ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xaases/aws/dynamodb.rb', line 19 def key_schema i = 0 keys.map do |key, type| i += 1 { "AttributeName" => key, "KeyType" => (i == 1 ? 'HASH' : 'RANGE') } end end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xaases/aws/dynamodb.rb', line 30 def to_hash { "Type" => 'AWS::DynamoDB::Table', "Properties" => { "TableName" => name, "AttributeDefinitions" => attribute_definitions, "KeySchema" => key_schema, "ProvisionedThroughput" => { "ReadCapacityUnits" => 1, "WriteCapacityUnits" => 1 } } } end |