Class: AWS::DynamoDB::PrimaryKeyElement
- Inherits:
-
Object
- Object
- AWS::DynamoDB::PrimaryKeyElement
- Defined in:
- lib/aws/dynamo_db/primary_key_element.rb
Constant Summary collapse
- ATTRIBUTE_TYPES =
{ "S" => :string, "N" => :number }
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ PrimaryKeyElement
constructor
A new instance of PrimaryKeyElement.
Constructor Details
#initialize(hash) ⇒ PrimaryKeyElement
Returns a new instance of PrimaryKeyElement.
27 28 29 30 |
# File 'lib/aws/dynamo_db/primary_key_element.rb', line 27 def initialize(hash) @name = hash[:name] || hash["AttributeName"] @type = hash[:type] || ATTRIBUTE_TYPES[hash["AttributeType"]] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/aws/dynamo_db/primary_key_element.rb', line 18 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
20 21 22 |
# File 'lib/aws/dynamo_db/primary_key_element.rb', line 20 def type @type end |
Class Method Details
.from_description(description) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aws/dynamo_db/primary_key_element.rb', line 32 def self.from_description(description) (name, type, *extra) = description.to_a.flatten raise(ArgumentError, "key element may contain only one name/type pair") unless extra.empty? raise ArgumentError, "unsupported type #{type.inspect}" unless ATTRIBUTE_TYPES.values.include?(type.to_sym) new(:name => name.to_s, :type => type) end |