Created
March 1, 2016 06:54
-
-
Save shio-phys/cde867561a0296298bd3 to your computer and use it in GitHub Desktop.
This file contains 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
# -*- coding: utf-8 -*- | |
require 'aws-sdk' | |
class DynamoDB | |
@@dynamodb = nil | |
def self.instance | |
return @@dynamodb if @@dynamodb | |
credentials = Aws::Credentials.new('aws_access_key', 'aws_secret_key') | |
dynamo_config = { region: 'ap-northeast-1', credentials: credentials, } | |
if Rails.env != 'production' #本番環境以外ではDynamoDB Localを利用 | |
dynamo_config[:endpoint] = "http://localhost:8000" | |
end | |
@@dynamodb = Aws::DynamoDB::Client.new(dynamo_config) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment