Module: Minidynamo::Model::DynamoDBOverloads::ClassMethods
- Defined in:
- lib/minidynamo/model/dynamo_db_overloads.rb
Instance Method Summary collapse
- #convert_key_to_dynamo_db_types(key) ⇒ Object
-
#create_table ⇒ Object
Changed: Don’t accept parameters when creating, use the declared options inside the model.
-
#dynamo_db_table(shard_name = nil) ⇒ DynamoDB::Table
private
changed to use hash key other than id.
Instance Method Details
#convert_key_to_dynamo_db_types(key) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/minidynamo/model/dynamo_db_overloads.rb', line 41 def convert_key_to_dynamo_db_types key keyname = key.keys[0] type = key[keyname] equivalent_type = nil case type when :float equivalent_type = :number when :integer equivalent_type = :number when :boolean equivalent_type = :number when :binary equivalent_type = :binary else equivalent_type = :string end key = {} key[keyname] = equivalent_type return key end |
#create_table ⇒ Object
Changed: Don’t accept parameters when creating, use the declared options inside the model
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/minidynamo/model/dynamo_db_overloads.rb', line 14 def create_table create_opts = {} create_opts[:hash_key] = convert_key_to_dynamo_db_types hash_key create_opts[:range_key] = convert_key_to_dynamo_db_types range_key if range_key dynamo_db.tables.create dynamo_db_table_name, read_capacity, write_capacity, create_opts end |
#dynamo_db_table(shard_name = nil) ⇒ DynamoDB::Table
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
changed to use hash key other than id
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/minidynamo/model/dynamo_db_overloads.rb', line 28 def dynamo_db_table shard_name = nil table = dynamo_db.tables[dynamo_db_table_name(shard_name)] table.hash_key = convert_key_to_dynamo_db_types(hash_key) #[:id, :string] table.range_key = convert_key_to_dynamo_db_types(range_key) if range_key #table.hash_key = {:public_token => :string } #table.range_key = {:created_at => :string } #table.hash_key = [:public_token, :string] #table.range_key = [:created_at, :string] table end |