Skip to content

Commit

Permalink
Fix handling custom type
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed Aug 4, 2018
1 parent 140c3e8 commit 8c04a12
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/dynamoid/primary_key_type_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
module Dynamoid
class PrimaryKeyTypeMapping
def self.dynamodb_type(type, options)
if Class === type
type = type.respond_to?(:dynamoid_field_type) ? type.dynamoid_field_type : :string
end

case type
when :string, :serialized
:string
Expand All @@ -22,8 +26,6 @@ def self.dynamodb_type(type, options)
options[:store_as_string]
end
string_format ? :string : :number
when Class
type.respond_to?(:dynamoid_field_type) ? type.dynamoid_field_type : :string
else
raise Errors::UnsupportedKeyType, "#{type} cannot be used as a type of table key attribute"
end
Expand Down

0 comments on commit 8c04a12

Please sign in to comment.