Method: PEROBS::DynamoDB#initialize
- Defined in:
- lib/perobs/DynamoDB.rb
#initialize(db_name, options = {}) ⇒ DynamoDB
Create a new DynamoDB object.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/perobs/DynamoDB.rb', line 46 def initialize(db_name, = {}) # :marshal serialization results in a binary format that cannot easily # be stored in DynamoDB. We fall back to :yaml. if [:serializer] == :marshal [:serializer] = :yaml end super([:serializer] || :json) if .include?(:aws_id) && .include?(:aws_key) Aws.config[:credentials] = Aws::Credentials.new([:aws_id], [:aws_key]) end if .include?(:aws_region) Aws.config[:region] = [:aws_region] end @dynamodb = Aws::DynamoDB::Client.new @table_name = db_name ensure_table_exists(@table_name) # Read the existing DB config. @config = get_hash('config') check_option('serializer') put_hash('config', @config) end |