Class: Dynamoid::AdapterPlugin::AwsSdkV2::Table
- Inherits:
-
Object
- Object
- Dynamoid::AdapterPlugin::AwsSdkV2::Table
- Defined in:
- lib/dynamoid/adapter_plugin/aws_sdk_v2.rb
Overview
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
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
-
#col_type(col) ⇒ Object
Returns the API type (e.g. “N”, “S”) for the given column, if the schema defines it, nil otherwise.
- #hash_key ⇒ Object
-
#initialize(schema) ⇒ Table
constructor
A new instance of Table.
- #item_count ⇒ Object
- #range_key ⇒ Object
- #range_type ⇒ Object
Constructor Details
#initialize(schema) ⇒ Table
Returns a new instance of Table.
987 988 989 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v2.rb', line 987 def initialize(schema) @schema = schema[:table] end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
982 983 984 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v2.rb', line 982 def schema @schema end |
Instance Method Details
#col_type(col) ⇒ Object
Returns the API type (e.g. “N”, “S”) for the given column, if the schema defines it, nil otherwise
1009 1010 1011 1012 1013 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v2.rb', line 1009 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 ⇒ Object
1001 1002 1003 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v2.rb', line 1001 def hash_key @hash_key ||= schema[:key_schema].find { |d| d[:key_type] == HASH_KEY }.try(:attribute_name).to_sym end |
#item_count ⇒ Object
1015 1016 1017 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v2.rb', line 1015 def item_count schema[:item_count] end |
#range_key ⇒ Object
991 992 993 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v2.rb', line 991 def range_key @range_key ||= schema[:key_schema].find { |d| d[:key_type] == RANGE_KEY }.try(:attribute_name) end |
#range_type ⇒ Object
995 996 997 998 999 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v2.rb', line 995 def range_type range_type ||= schema[:attribute_definitions].find { |d| d[:attribute_name] == range_key }.try(:fetch, :attribute_type, nil) end |