Class: DynamoLocalRuby::SchemaLoader
- Inherits:
-
Object
- Object
- DynamoLocalRuby::SchemaLoader
- Defined in:
- lib/dynamo-local-ruby/schema_loader.rb
Overview
Helper for creating tables from a schema definition
Instance Method Summary collapse
-
#initialize(dynamo_client) ⇒ SchemaLoader
constructor
A new instance of SchemaLoader.
-
#load(schema) ⇒ Object
Expect schema to have form { ‘table_name’ => { keys: { ‘foo’ => { attribute_type: ‘S’, key_type: ‘HASH’ } }, capacity: { read: 1, write: 1 } # optional } }.
Constructor Details
#initialize(dynamo_client) ⇒ SchemaLoader
Returns a new instance of SchemaLoader.
8 9 10 |
# File 'lib/dynamo-local-ruby/schema_loader.rb', line 8 def initialize(dynamo_client) @dynamo = Aws::DynamoDB::Resource.new(client: dynamo_client) end |
Instance Method Details
#load(schema) ⇒ Object
Expect schema to have form {
'table_name' => {
keys: {
'foo' => { attribute_type: 'S', key_type: 'HASH' }
},
capacity: { read: 1, write: 1 } # optional
}
}
21 22 23 |
# File 'lib/dynamo-local-ruby/schema_loader.rb', line 21 def load(schema) schema.each { |name, table_schema| load_table(name, table_schema) } end |