Created
August 13, 2017 17:26
-
-
Save 8parth/65186f32f29488333cbc06389096db73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class DynamoDBConfig | |
include Singleton | |
attr_reader :client, :configs | |
def initialize | |
@configs ||= { | |
access_key_id: Rails.application.secrets.aws_access_key_id, | |
secret_access_key: Rails.application.secrets.aws_secret_access_key, | |
region: Rails.application.secrets.aws_region | |
} | |
case Rails.env | |
when 'test', 'development' | |
configs[:endpoint] = 'http://localhost:8000' | |
configs[:logger] = Rails.logger | |
end | |
@client ||= Aws::DynamoDB::Client.new(configs) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment