class Dymos::Query::CreateTable
Public Instance Methods
attributes(value)
click to toggle source
# File lib/dymos/query/create_table.rb, line 8 def attributes(value) @query[:attribute_definitions] = _attributes(value) self end
command()
click to toggle source
# File lib/dymos/query/create_table.rb, line 4 def command 'create_table' end
gsi(value)
click to toggle source
# File lib/dymos/query/create_table.rb, line 42 def gsi(value) @query[:global_secondary_indexes] = value.map { |i| index = _index(i) index[:provisioned_throughput] = _throughput(i[:throughput]) index } self end
keys(value)
click to toggle source
# File lib/dymos/query/create_table.rb, line 19 def keys(value) @query[:key_schema]=_keys(value) self end
lsi(value)
click to toggle source
# File lib/dymos/query/create_table.rb, line 51 def lsi(value) @query[:local_secondary_indexes] = value.map do |i| _index(i) end self end
throughput(value)
click to toggle source
# File lib/dymos/query/create_table.rb, line 30 def throughput(value) @query[:provisioned_throughput] = _throughput(value) self end
Private Instance Methods
_attributes(value)
click to toggle source
# File lib/dymos/query/create_table.rb, line 13 def _attributes(value) value.map { |k, v| {attribute_name: k.to_s, attribute_type: v.to_s} } end
_index(i)
click to toggle source
# File lib/dymos/query/create_table.rb, line 58 def _index(i) index = {} index[:index_name] = i[:name] index[:key_schema] = _keys(i[:keys]) index[:projection]= _projection_type(i) index[:projection][:non_key_attributes] = i[:projection][:attributes] if i.try(:[], :projection).try(:[], :attributes).present? index end
_keys(value)
click to toggle source
# File lib/dymos/query/create_table.rb, line 24 def _keys(value) value.map { |k, v| {attribute_name: k.to_s, key_type: v.to_s} } end
_projection_type(i)
click to toggle source
# File lib/dymos/query/create_table.rb, line 67 def _projection_type(i) {projection_type: (i.try(:[], :projection).try(:[], :type) || 'ALL').to_s} end
_throughput(value)
click to toggle source
# File lib/dymos/query/create_table.rb, line 35 def _throughput(value) { read_capacity_units: value[:read], write_capacity_units: value[:write] } end