Module: Arc::Tables
- Defined in:
- lib/architect/tables.rb
Class Method Summary collapse
-
.name(tablename:) ⇒ Object
returns the physicalID for the given table name.
- .port ⇒ Object
-
.table(tablename:) ⇒ Object
returns Aws::DynamoDB::Table docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Table.html.
Class Method Details
.name(tablename:) ⇒ Object
returns the physicalID for the given table name
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/architect/tables.rb', line 24 def self.name(tablename:) if ENV['NODE_ENV'] == 'testing' tmp = "staging-#{tablename}" db = Aws::DynamoDB::Resource.new endpoint: "http://localhost:#{Arc::Tables.port}" tbl = db.tables().detect {|e| e.name.include?(tmp)} tbl.name else arc = Arc.reflect arc['tables'][tablename] end end |
.port ⇒ Object
36 37 38 |
# File 'lib/architect/tables.rb', line 36 def self.port ENV.fetch('ARC_TABLES_PORT') { 5555 } end |
.table(tablename:) ⇒ Object
returns Aws::DynamoDB::Table docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Table.html
12 13 14 15 16 17 18 19 |
# File 'lib/architect/tables.rb', line 12 def self.table(tablename:) ddb = if ENV['NODE_ENV'] == 'testing' Aws::DynamoDB::Resource.new endpoint: "http://localhost:#{Arc::Tables.port}" else Aws::DynamoDB::Resource.new end ddb.table(Arc::Tables.name(tablename: tablename)) end |