class Dynamoid::AdapterPlugin::AwsSdkV3::Table
Represents a table. Exposes data from the “DescribeTable” API call, and also provides methods for coercing values to the proper types based on the table’s schema data
Attributes
schema[R]
Public Class Methods
new(schema)
click to toggle source
@param [Hash] schema Data returns from a “DescribeTable” call
# File lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb, line 15 def initialize(schema) @schema = schema[:table] end
Public Instance Methods
col_type(col)
click to toggle source
Returns the API type (e.g. “N”, “S”) for the given column, if the schema defines it, nil otherwise
# File lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb, line 37 def col_type(col) col = col.to_s col_def = schema[:attribute_definitions].find { |d| d[:attribute_name] == col.to_s } col_def && col_def[:attribute_type] end
hash_key()
click to toggle source
# File lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb, line 29 def hash_key @hash_key ||= schema[:key_schema].find { |d| d[:key_type] == HASH_KEY }.try(:attribute_name).to_sym end
item_count()
click to toggle source
# File lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb, line 43 def item_count schema[:item_count] end
name()
click to toggle source
# File lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb, line 47 def name schema[:table_name] end
range_key()
click to toggle source
# File lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb, line 19 def range_key @range_key ||= schema[:key_schema].find { |d| d[:key_type] == RANGE_KEY }.try(:attribute_name) end
range_type()
click to toggle source
# File lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb, line 23 def range_type range_type ||= schema[:attribute_definitions].find do |d| d[:attribute_name] == range_key end.try(:fetch, :attribute_type, nil) end