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, "B" => :binary, }
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.
28 29 30 31 |
# File 'lib/aws/dynamo_db/primary_key_element.rb', line 28 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
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/aws/dynamo_db/primary_key_element.rb', line 33 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 |