Class: FakeDynamo::KeySchema

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_dynamo/key_schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_schema, attribute_definitions) ⇒ KeySchema

Returns a new instance of KeySchema.



6
7
8
# File 'lib/fake_dynamo/key_schema.rb', line 6

def initialize(key_schema, attribute_definitions)
  extract_values(key_schema, attribute_definitions)
end

Instance Attribute Details

#hash_keyObject

Returns the value of attribute hash_key.



4
5
6
# File 'lib/fake_dynamo/key_schema.rb', line 4

def hash_key
  @hash_key
end

#range_keyObject

Returns the value of attribute range_key.



4
5
6
# File 'lib/fake_dynamo/key_schema.rb', line 4

def range_key
  @range_key
end

Instance Method Details

#descriptionObject



10
11
12
13
14
15
16
# File 'lib/fake_dynamo/key_schema.rb', line 10

def description
  description = [{'AttributeName' => hash_key.name, 'KeyType' => 'HASH'}]
  if range_key
    description << {'AttributeName' => range_key.name, 'KeyType' => 'RANGE'}
  end
  description
end

#keysObject



18
19
20
21
22
23
24
# File 'lib/fake_dynamo/key_schema.rb', line 18

def keys
  result = [hash_key.name]
  if range_key
    result << range_key.name
  end
  result
end