Class: Dynamoid::AdapterPlugin::AwsSdkV3::Table
- Inherits:
-
Object
- Object
- Dynamoid::AdapterPlugin::AwsSdkV3::Table
- Defined in:
- lib/dynamoid/adapter_plugin/aws_sdk_v3/table.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
- #arn ⇒ Object
-
#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
- #local! ⇒ Object
- #local? ⇒ Boolean
- #name ⇒ Object
- #range_key ⇒ Object
- #range_type ⇒ Object
Constructor Details
#initialize(schema) ⇒ Table
Returns a new instance of Table.
15 16 17 18 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 15 def initialize(schema) @schema = schema[:table] @local = false end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
10 11 12 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 10 def schema @schema end |
Instance Method Details
#arn ⇒ Object
52 53 54 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 52 def arn schema[:table_arn] end |
#col_type(col) ⇒ Object
Returns the API type (e.g. “N”, “S”) for the given column, if the schema defines it, nil otherwise
38 39 40 41 42 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 38 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
30 31 32 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 30 def hash_key @hash_key ||= schema[:key_schema].find { |d| d[:key_type] == HASH_KEY }.try(:attribute_name).to_sym end |
#item_count ⇒ Object
44 45 46 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 44 def item_count schema[:item_count] end |
#local! ⇒ Object
56 57 58 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 56 def local! @local = true end |
#local? ⇒ Boolean
60 61 62 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 60 def local? @local end |
#name ⇒ Object
48 49 50 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 48 def name schema[:table_name] end |
#range_key ⇒ Object
20 21 22 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 20 def range_key @range_key ||= schema[:key_schema].find { |d| d[:key_type] == RANGE_KEY }.try(:attribute_name) end |
#range_type ⇒ Object
24 25 26 27 28 |
# File 'lib/dynamoid/adapter_plugin/aws_sdk_v3/table.rb', line 24 def range_type range_type ||= schema[:attribute_definitions].find do |d| d[:attribute_name] == range_key end.try(:fetch, :attribute_type, nil) end |